|
-
Nov 22nd, 2008, 06:09 PM
#1
Thread Starter
Junior Member
need help guys
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
-
Nov 22nd, 2008, 08:05 PM
#2
Re: need help guys
So what actually happens when you execute that code? Is there any error message, or does the code execute without error? If it does execute without error then how exactly are you determining that it's not working?
I would suggest that you follow the second link in my signature if you're using a SQL Server Express database that you added directly to your project. I'd also suggest following the Data Access link in my signature and paying special attention to the bit about Update being a function and what it returns.
-
Nov 23rd, 2008, 12:12 AM
#3
Thread Starter
Junior Member
Re: need help guys
thanks for the post......
Actually when I execute the code,...... there is no error message....
well my problem is I want the XMLnode (title,description and url) to be saved to a database, but no data is being save eventhough there is no error while executing the codes. thanks........
-
Nov 23rd, 2008, 02:43 AM
#4
Re: need help guys
Then you need to answer my second question:
If it does execute without error then how exactly are you determining that it's not working?
and probably follow the advice I provided:
I would suggest that you follow the second link in my signature if you're using a SQL Server Express database that you added directly to your project.
which explains how to fix the most common cause of this complaint.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|