I hope that someonw can help me with this. This code is inteneded to add a new column to a mariaDB based on data extracted from a filename. I get the error " near @sname = s111206 syntax error. The variable @sname contains the proper data for the text file. I am new to working with databases so forgive me my ignorance.
I have tried several variation of the sql but have not had any luck, and have not been able to find an answer in the connector.net help. Thanks for your consideration.
Jules
(julesjenson@me.com)
sxxxxxx would be s111206, always plus six digits
'create column for filename date as sxxxxxx
Try
conn.Open()
Dim sql As String
Dim adapter As New MySqlDataAdapter
Dim command As New MySqlCommand
sql = ("ALTER TABLE attendance ADD @sname varchar(14)")
command.CommandText = sql
command.Connection = conn
adapter.SelectCommand = command
command.Prepare()
command.Parameters.AddWithValue("@sname", sname)
command.ExecuteNonQuery()
Catch ex As MySql.Data.MySqlClient.MySqlException
MessageBox.Show(ex.Message)
End Try
If I change @sname to sname, I get a column named 'sname'. I would really like it to be sxxxxxx, that way each week when the software
executes to would create the column and update based upon the file
contents.
conn.Close()
I have tried several variation of the sql but have not had any luck, and have not been able to find an answer in the connector.net help. Thanks for your consideration.
Jules
(julesjenson@me.com)
sxxxxxx would be s111206, always plus six digits
'create column for filename date as sxxxxxx
Try
conn.Open()
Dim sql As String
Dim adapter As New MySqlDataAdapter
Dim command As New MySqlCommand
sql = ("ALTER TABLE attendance ADD @sname varchar(14)")
command.CommandText = sql
command.Connection = conn
adapter.SelectCommand = command
command.Prepare()
command.Parameters.AddWithValue("@sname", sname)
command.ExecuteNonQuery()
Catch ex As MySql.Data.MySqlClient.MySqlException
MessageBox.Show(ex.Message)
End Try
If I change @sname to sname, I get a column named 'sname'. I would really like it to be sxxxxxx, that way each week when the software
executes to would create the column and update based upon the file
contents.
conn.Close()