connection string for OLEDB2 provider..using C#
-
please.. i need a sample... or please check if somethings wrong in this program..its not saving..and i think the connection string is not valid but it doesnt build any errors until you save in the database. OleDbConnection connect=new OleDbConnection(); connect.ConnectionString="PROVIDER=DB2OLEDB; initial catalog=SAMPLE;integrated security=SSPI"; connect.Open(); OleDbCommand cmd_save =new OleDbCommand("INSERT INTO test(name,year,course)"+"VALUES("+"'"+textBox1.Text+"'"+","+"'"+textBox2.Text+"'"+","+"'"+textBox3.Text+"'"+")",connect); cmd_save.ExecuteNonQuery(); connect.Close(); thanks for the help..
-
please.. i need a sample... or please check if somethings wrong in this program..its not saving..and i think the connection string is not valid but it doesnt build any errors until you save in the database. OleDbConnection connect=new OleDbConnection(); connect.ConnectionString="PROVIDER=DB2OLEDB; initial catalog=SAMPLE;integrated security=SSPI"; connect.Open(); OleDbCommand cmd_save =new OleDbCommand("INSERT INTO test(name,year,course)"+"VALUES("+"'"+textBox1.Text+"'"+","+"'"+textBox2.Text+"'"+","+"'"+textBox3.Text+"'"+")",connect); cmd_save.ExecuteNonQuery(); connect.Close(); thanks for the help..
Check this to get some help with the connection string. http://www.carlprothman.net/Default.aspx?tabid=86#OLEDBManagedProvider But it sure seems odd that the error isn't raised when the Open() method is called. Must be the INSERT statement that's wrong. I don't know for sure if it's ok to write the ending ) of the data declaration without any space before VALUES( ... ) declaration. I can also recommend you to start using SqlParameter to get a safer and smoother SQL handling. Take a look here for a quick example: http://www.samspublishing.com/articles/article.asp?p=27640&seqNum=6&rl=1 Hope it helps some
-
Check this to get some help with the connection string. http://www.carlprothman.net/Default.aspx?tabid=86#OLEDBManagedProvider But it sure seems odd that the error isn't raised when the Open() method is called. Must be the INSERT statement that's wrong. I don't know for sure if it's ok to write the ending ) of the data declaration without any space before VALUES( ... ) declaration. I can also recommend you to start using SqlParameter to get a safer and smoother SQL handling. Take a look here for a quick example: http://www.samspublishing.com/articles/article.asp?p=27640&seqNum=6&rl=1 Hope it helps some
-
thanks.. its now running. But the problem is that i cant save data on the database. The exception is that the provider=DB2OLEDB is not available in the local machine. it highlights the statement where i insert values. thanks.