Insert Dataset into SQL Database.

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2004
Posts: 4
Reputation: Devin is an unknown quantity at this point 
Solved Threads: 0
Devin Devin is offline Offline
Newbie Poster

Insert Dataset into SQL Database.

 
0
  #1
Dec 22nd, 2004
Okay heres the dilemna....

I have a Dataset("LineItems") that Stores information about so many records.

To source to this DataSet("LineItems") is not its intended ouput.

Meaning I pull this info in from one database and output to another.

My problem is i have no idea on how to write an insert statement that will insert multiple records into a SQL table. Does anyone have any pointers????

PLEASE HELP ASAP. THANKS!
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 23
Reputation: bruce2424 is an unknown quantity at this point 
Solved Threads: 0
bruce2424 bruce2424 is offline Offline
Newbie Poster

Re: Insert Dataset into SQL Database.

 
0
  #2
Nov 8th, 2008
for int i=0 to dataset.tables(0).rows.count -1
adapter.InsertCommand = New SqlCommand(insertSQL, connection)
adapter.InsertCommand.ExecuteNonQuery()
next i

http://vb.net-informations.com/dataa...-sqlserver.htm

http://vb.net-informations.com/datas...et-dataset.htm

bruce
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 1
Reputation: prit49 is an unknown quantity at this point 
Solved Threads: 0
prit49 prit49 is offline Offline
Newbie Poster

Re: Insert Dataset into SQL Database.

 
0
  #3
Nov 9th, 2008
in a form , I set dtpicker ( date calender ) , it is ok, i choose a date ( dd/mm/yyyy) format ( 15 /10/2008 ) , when it save in database field , it say wrong . i want my all date field will save and retrieve ( when modify ) in (dd/mm/yyyy) format. how is it possible.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 144
Reputation: sierrainfo is an unknown quantity at this point 
Solved Threads: 9
sierrainfo sierrainfo is offline Offline
Junior Poster

Re: Insert Dataset into SQL Database.

 
0
  #4
Nov 18th, 2008
Imports System.Data.SqlClient
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connetionString As String
Dim connection As SqlConnection
Dim adapter As New SqlDataAdapter
Dim sql As String
connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"
connection = New SqlConnection(connetionString)
sql = "insert into product (Product_id,Product_name,Product_price) values(7,'Product7',700)"
Try
connection.Open()
adapter.InsertCommand = New SqlCommand(sql, connection)
adapter.InsertCommand.ExecuteNonQuery()
MsgBox("Row inserted !! ")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 144
Reputation: sierrainfo is an unknown quantity at this point 
Solved Threads: 9
sierrainfo sierrainfo is offline Offline
Junior Poster

Re: Insert Dataset into SQL Database.

 
0
  #5
Nov 18th, 2008
Use Format Function.
Like :

= Format(dtpicker .Value, "dd/MM/yyyy")
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC