need help guys any idea would be a good help for me Im just starting vb.net
I cant update my database I know that there is something wrong here...
God Bless U All![]()
Code:Public Sub ConnectXML(ByVal strURL As String) 'database Dim jinObjConnection As SqlConnection = GetConnection() jinObjConnection.Open() Dim strSelectQuery As String = "SELECT * FROM tbl_channel" Dim jinObjAdapter = New SqlClient.SqlDataAdapter(strSelectQuery, jinObjConnection) Dim strInsertQuery As New SqlCommand("INSERT INTO tbl_channel VALUES(@[Title],@[Description],@[URL],@[LastUpdated],@[TitleID])", jinObjConnection) 'Dim jinDataset As New DataSet strInsertQuery.Parameters.Add("@[Title]", SqlDbType.Text, 50, "[Title]") strInsertQuery.Parameters.Add("@[Description]", SqlDbType.Text, 50, "[Description]") strInsertQuery.Parameters.Add("@[URL]", SqlDbType.Text, 50, "[URL]") strInsertQuery.Parameters.Add("@[LastUpdated]", SqlDbType.DateTime, 8, "[LastUpdated]") strInsertQuery.Parameters.Add("@[TitleID]", SqlDbType.BigInt, 20, "[TitleID]") jinObjAdapter.InsertCommand = strInsertQuery jinObjAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey Dim jinTable As New DataTable jinObjAdapter.FillSchema(jinTable, SchemaType.Source) Dim jinDataRow As DataRow = jinTable.NewRow Dim myRequestURL As WebRequest = WebRequest.Create(strURL) Dim myResponse2URL As WebResponse = myRequestURL.GetResponse Dim Rss_StreamReader As Stream = myResponse2URL.GetResponseStream Dim Rss_object As New StreamReader(Rss_StreamReader) Dim Rss_document As New XmlDocument On Error Resume Next Rss_document.LoadXml(Rss_object.ReadToEnd) Dim RssItems_xml As XmlNodeList = Rss_document.SelectNodes("rss/channel/item") For intCounter = 0 To RssItems_xml.Count - 1 ' for every node that is being read and loaded Dim RssDetails As XmlNode RssDetails = RssItems_xml.Item(intCounter).SelectSingleNode("title") If RssDetails.Equals(Nothing) = False Then jinDataRow("Title") = RssDetails.InnerText Else jinDataRow("Title") = Nothing End If RssDetails = RssItems_xml.Item(intCounter).SelectSingleNode("description") If RssDetails.Equals(Nothing) = False Then jinDataRow("Description") = RssDetails.InnerText Else jinDataRow("Description") = Nothing End If RssDetails = RssItems_xml.Item(intCounter).SelectSingleNode("link") If RssDetails.Equals(Nothing) = False Then jinDataRow("URL") = RssDetails.InnerText Else jinDataRow("URL") = Nothing End If jinDataRow("LastUpdated") = Now jinDataRow("TitleID") = intTitle jinTable.Rows.Add(jinDataRow) 'jinDataset.Tables(0).Rows.Add(jinDataRow) jinObjAdapter.Update(jinTable) 'jinDataset.AcceptChanges() Next ' ' jinObjAdapter.Dispose() 'jinObjConnection.Close() 'jinObjConnection.Dispose() ' xml End Sub




Reply With Quote