VBA populate label from database
Posted on 2006-03-22
Hello, I'm trying to populate a label from the data that is being returned from a SQL query, but keep getting an error: must declare the varible @stringm163
Can someone please look at my code below and show me where I'm going wrong?
Dim conn As ADODB.Connection
Dim connString As String
connString = "Provider=sqloledb;Data Source=localhost;Initial Catalog=test;User Id=scott;Password=rocks"
Set conn = New ADODB.Connection
conn.ConnectionString = connString
Dim rs As ADODB.Recordset
Dim sSQL As String
Set rs = New ADODB.Recordset
sSQL = "select username from cstb_sopWindowUsers where username = @StringM163"
rs.Open sSQL, conn
StringM164.Value = rs.Fields.Item("username").Value
Set conn = Nothing
Set rs = Nothing