sweetness,
you have to use dataAdapter with dataset
Or you only use SQLcommand to insert record.
some code here.
Usind dataAdapter
SQLCOmmand.conn ection = SQLCOnnection
dim commandBuilder as SQLCommandBuild er
SQLCommand.comm andtext = "Select * from Table"
dataadapter.sel ectCommand = SQLCommand
CommandBuilder = new SQLCommandBuild er(dataAdapter)
dataadapter.fil l(dataset,"tabl e")
dataRow = dataset.table(0 ).newRow
dataRow(0) = value1
dataRow(1) = value2
dataset.table(1 ).rows.add(data row)
commandBuilder. refreshSchema()
dataAdapter.Upd ate(dataset,"ta ble")
---------------
Using SQLCOmmand
SQLCOmmand.conn ection = SQLCOnnection
SQLCommand.comm andtext = "Insert into table value @1, @2"
SQLCOmmand.para meters.add("@1" )
SQLCommand.para meters.add("@2" )
SQLCommand.para meters("@1").va lue = value1
SQLCommand.para meters("@2").va lue = value2
SQLCommand.Exec uteNonQuery;
Hope it can help you
Kwok
-----Original Message-----
I'm new to this and desperately need help, I'm trying to
insert into an sql db and i have no idea what to do and
why.
i created an sqladapter, and an sqlconnection by dragging
and dropping.
this is a piece of my code:
Try
Me.SqlInsertCom mand1.CommandTe xt = "INSERT INTO
StudentInfo(ST UDENTID, SURNAME, FIRST_NAMES, PASSWORD,
GENDER, RESIDENCE) VALUES(' " & sNumber.Text & " ' ,' " &
surname.Text & " ' , ' " & fNames.Text & " ' , ' " &
pass.Text & " ' , ' " & gender.Selected Item.Text
& " ' , ' " & res.Text & " ' )"
Me.SqlInsertCom mand1.Connectio n =
Me.SqlConnecti on1
Me.SqlDataAdapt er1.SelectComma nd =
Me.SqlInsertCo mmand1
SqlConnection1. Open()
SqlInsertComman d1.ExecuteNonQu ery()
Catch d As Exception
Console.WriteLi ne(d.Message)
End Try
Console.WriteLi ne("Record Added")
.