Pass value of a ComboBox in SQL statement

CharlieChau

Active member
Joined
Jun 15, 2004
Messages
26
Programming Experience
Beginner
Hi,

Could someone help me to pass a value of a ComboBox into in a SQL statement, please.

Thanks,
/CC.
 
'SqlSelectCommand1
'
Me.SqlSelectCommand1.CommandText = "SELECT [Part Name], [Part Number] FROM Part WHERE ([Part Name] = @variable)"
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
Me.SqlSelectCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@variable", System.Data.SqlDbType.BigInt, 8, "Part Name"))


Dim variable1 As String
variable1 = ComboBox1.Text
SqlSelectCommand1.Parameters("@variable").Value = variable1

Me.LoadDataSet()

 
VB.NET:
 'cn is a connection
 dim cm as new sqlcommand("insert into sampletable(name) values '" & combobox1.text & "'",cn)
 
Back
Top