473,417 Members | 1,482 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,417 software developers and data experts.

Could not open Connection to SQL Server.

80 64KB
I'm getting this error.

SQLite error
near "16": syntax error

On the code:

Expand|Select|Wrap|Line Numbers
  1.  private void btnUpdate_Click(object sender, EventArgs e)
  2.         {
  3.             for (int i = 0; i < dataGridView1.Rows.Count; i++)
  4.             {
  5.                 string StrQuery = @"INSERT INTO Test VALUES (" + dataGridView1.Rows[i].Cells["Column1"].Value + ", " + dataGridView1.Rows[i].Cells["Column2"].Value + ", " + dataGridView1.Rows[i].Cells["Column3"].Value + ", " + dataGridView1.Rows[i].Cells["Column4"].Value + ", " + dataGridView1.Rows[i].Cells["Column5"].Value +");";
  6.  
  7.                 try
  8.                 {
  9.                     SQLiteConnection conn = new SQLiteConnection(connString);
  10.                     conn.Open();
  11.                     using (SQLiteCommand comm = new SQLiteCommand(StrQuery, conn))
  12.                     {
  13.                         comm.ExecuteNonQuery();
  14.                     }
  15.                     conn.Close();
  16.                 }
  17.                 catch (Exception crap)
  18.                 {
  19.                     MessageBox.Show(crap.ToString());
  20.                 }
  21.             }
  22.         }
With breapoints etc it does show the values it has to insert into my database. But it just doesn't and gives me the Near "16" syntax error. Am I just beng stupid and overlooking something or is my code just totally wrong?
Feb 19 '13
50 4148
M1kkelZU
80 64KB
Yeah and now I can pass this wisdom on to my noobier friends and be seen as a God to them lol. I really appreciate all your help man.
Mar 6 '13 #51

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: PAM | last post by:
Hello I'm a newbie trying to open a connection to an Excel file in a deployed ASP .NET app and get the error Dim MyCommand As New OleDbCommand(mySelectQuery, MyConnection MyConnection.Open(
5
by: Owen | last post by:
Hello: How know how many open connection have my application made in asp.net?, To know if a open a new connection and not close? Best regards. Owen.
2
by: Rafi B. | last post by:
Sorry for the English. I mean, when building my applications, I often need to do several database actions, and I'm thinking, what's better? 1) Open connection with DB, for instance mySQL, at...
1
by: Michael Swinarski | last post by:
I am working on setting up our new SQL Server 2005 servers. One of them will eventually be our Replication Distributor. However when I attempt to set this up within the wizard, I get the...
12
idsanjeev
by: idsanjeev | last post by:
how to open connection in oracle for displying and inserting data in asp.net with vb
1
by: Bruno Marinho | last post by:
Hi, I'm having a problem creating an OU entry on a Open LDAP Server. I'm using the code below. $ad = ldap_connect("ldap://srvldap"); ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3); $bd =...
1
by: Noorain | last post by:
hi, i create a php file. which function is: i)to refresh a certain time ii)create txt file with some query. i want to this php file always open in server and refresh after 5 minutes. i know...
2
by: KKAIYER | last post by:
I am using VB6,SQL Server,Crystall reports. when I run vb to print report crystal repots giving error 20599 cannot open SQL Server. what is the reason and what is the solution. Please help
1
by: vj4u | last post by:
i want to open sql server on button click in asp.net
1
by: Vinayak Pangam | last post by:
When I open the server it shows a duplicate name exists on the network. It affects the workstation also. I also check in all pc no duplicate name exits. Please give me a solution what is the exact...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.