sweetness,
you have to use dataAdapter with dataset
Or you only use SQLcommand to insert record.
some code here.
Usind dataAdapter
SQLCOmmand.connection = SQLCOnnection
dim commandBuilder as SQLCommandBuilder
SQLCommand.commandtext = "Select * from Table"
dataadapter.selectCommand = SQLCommand
CommandBuilder = new SQLCommandBuilder(dataAdapter)
dataadapter.fill(dataset,"table")
dataRow = dataset.table(0).newRow
dataRow(0) = value1
dataRow(1) = value2
dataset.table(1).rows.add(datarow)
commandBuilder.refreshSchema()
dataAdapter.Update(dataset,"table")
---------------
Using SQLCOmmand
SQLCOmmand.connection = SQLCOnnection
SQLCommand.commandtext = "Insert into table value @1, @2"
SQLCOmmand.parameters.add("@1")
SQLCommand.parameters.add("@2")
SQLCommand.parameters("@1").value = value1
SQLCommand.parameters("@2").value = value2
SQLCommand.ExecuteNonQuery;
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.SqlInsertCommand1.CommandText = "INSERT INTO
StudentInfo(STUDENTID, SURNAME, FIRST_NAMES, PASSWORD,
GENDER, RESIDENCE) VALUES(' " & sNumber.Text & " ' ,' " &
surname.Text & " ' , ' " & fNames.Text & " ' , ' " &
pass.Text & " ' , ' " & gender.SelectedItem.Text
& " ' , ' " & res.Text & " ' )"
Me.SqlInsertCommand1.Connection =
Me.SqlConnection1
Me.SqlDataAdapter1.SelectCommand =
Me.SqlInsertCommand1
SqlConnection1.Open()
SqlInsertCommand1.ExecuteNonQuery()
Catch d As Exception
Console.WriteLine(d.Message)
End Try
Console.WriteLine("Record Added")
.