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.
 

DavidT_macktool

Well-known member
Joined
Oct 21, 2004
Messages
502
Location
Indiana
Programming Experience
3-5
'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()

 

mzim

Well-known member
Joined
Jun 3, 2004
Messages
187
Location
Other side of the rock
Programming Experience
1-3
VB.NET:
 'cn is a connection
 dim cm as new sqlcommand("insert into sampletable(name) values '" & combobox1.text & "'",cn)
 
Top Bottom