1.我想要在datalist1中点击文章的分类,然后在datalist2中显示该分类的所有文章,可是用以下代码点击文章分类后永远都是显示没有相关文章,请问这是怎么回事啊?datalist1的数据源是datasource1,datalist2的数据源是datalist2.
Dim str As String
str = Request.QueryString("ClassId")
If String.IsNullOrEmpty(str) Then
DataList2.DataSourceID = SqlDataSource2.ID
Else
DataList2.DataSourceID = SqlDataSource3.ID
If DataList2.Items.Count = 0 Then
Label2.Text = "没有相关文章!"
End If
End If
2.点击刚才的datalist2的一个标题后将进入文章浏览页面,我先创建了一个oledbdataadapter对象,然后利用该对象的fill方法将查询的内容填充至dataset对象中,最后利用label和div控件显示dataset对象中的数据.可是敲入以下代码后编译报错"语法错误 (操作符丢失) 在查询表达式 'id=' 中"
Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source=" + Server.MapPath("blog.mdb")
Dim oleDbConn As OleDbConnection
oleDbConn = New OleDbConnection(strConn)
Dim oleAdp As OleDbDataAdapter
oleAdp = New OleDbDataAdapter("select*from blog where id=" + Request.QueryString("Id"), oleDbConn)
Dim ds As Data.DataSet = New Data.DataSet
oleAdp.Fill(ds, "blog")(它说这句有问题?)
Dim dr As Data.DataRow
dr = ds.Tables("blog").NewRow()
dr = ds.Tables("blog").Rows.Item(0)
Label1.Text = dr("title").ToString()
DIV1.InnerHtml = toHtml(dr("content").ToString())
Label2.Text = "[发布时间:" + dr("date") + "]"
3.下面是发表文章的页面,将文章内容写入数据库,可是当写入的时候会这样报错"INSERT INTO 语句的语法错误。"
If TextBox1.Text = "" Then
End If
Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source=" + Server.MapPath("blog.mdb")
Dim oleDbConn As OleDbConnection
oleDbConn = New OleDbConnection(strConn)
Dim oleDbCmd As OleDbCommand = oleDbConn.CreateCommand()
Dim strCmd As String = "insert into" & "blog(title,content,date,classId) Values('"
strCmd &= TextBox1.Text + "','" + TextBox2.Text + "','" + DateTime.Now.ToString() + "','"
strCmd &= DropDownList1.SelectedValue + "')"
oleDbCmd.CommandText = strCmd
oleDbConn.Open()
Dim i As Integer = oleDbCmd.ExecuteNonQuery()(就说的是这句)
oleDbConn.Close()
Response.Redirect("NewsMag.aspx")
以上问题能回答几个就回答几个,急用!最多挂三天!以上是我用visual studio 2005 做的,语言是vb.