Problem uploading to MS SQL server

Problem uploading to MS SQL server

Postby codemonkey2003 » Tue 27 Mar 2007 17:15

Hi,

I get an error message from UniDirect that prevents me from uploading data to my MS SQL server:

System.InvalidOperationException: Connection must be opened
at CoreLab.UniDirect.UniCommand.m()
at CoreLab.UniDirect.UniCommand.a(CommandBehavior A_0, IDisposable A_1, Int32 A_2, Int32 A_3, Boolean A_4)
at CoreLab.UniDirect.UniCommand.ExecuteNonQuery()
at WindowsApplication1.MainForm.button16_Click(Object sender, EventArgs e) in c:\sai development\sai c sharp projects\sai beta\windowsapplication1\mainform1.cs:line 2835


These are the dll's loaded when the program starts:
'DefaultDomain': Loaded 'c:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded.
'WindowsApplication1': Loaded 'C:\SAI Development\SAI C SHARP Projects\SAI Beta\WindowsApplication1\bin\Debug\WindowsApplication1.exe', Symbols loaded.
'WindowsApplication1.exe': Loaded 'c:\windows\assembly\gac\system.windows.forms\1.0.5000.0__b77a5c561934e089\system.windows.forms.dll', No symbols loaded.
'WindowsApplication1.exe': Loaded 'c:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No symbols loaded.
'WindowsApplication1.exe': Loaded 'c:\sai development\sai c sharp projects\sai beta\windowsapplication1\bin\debug\threadlib.dll', Symbols loaded.
'WindowsApplication1.exe': Loaded 'c:\windows\assembly\gac\pegasusimaging.winforms.imagxpress7\7.0.60.0__80d669b8b606a2da\pegasusimaging.winforms.imagxpress7.dll', No symbols loaded.
'WindowsApplication1.exe': Loaded 'c:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded.
'WindowsApplication1.exe': Loaded 'c:\windows\assembly\gac\corelab.unidirect\2.0.4.0__09af7300eec23701\corelab.unidirect.dll', No symbols loaded.
'WindowsApplication1.exe': Loaded 'c:\windows\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll', No symbols loaded.
'WindowsApplication1.exe': Loaded 'c:\windows\assembly\gac\corelab.mysql\2.70.1.0__09af7300eec23701\corelab.mysql.dll', No symbols loaded.
'WindowsApplication1.exe': Loaded 'c:\windows\assembly\gac\accessibility\1.0.5000.0__b03f5f7f11d50a3a\accessibility.dll', No symbols loaded.
'WindowsApplication1.exe': Loaded 'c:\windows\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll', No symbols loaded.


The code looks like this:
-----------------------------


UniConnection connection = new UniConnection("Provider=SQL Server;server=192.168.1.109;user id=troy;password=troy;initial catalog=poop");
try {
UniCommand cmd = connection.CreateCommand();

cmd.CommandText = "INSERT INTO "+"weathertable"+" (winddirection,windspeed,windvar,windgust,temperature,dewpoint,time,date,heatindex,windchill,relativehumidity,thunderstorm,visibility,ceiling,altimeter,densityaltitude,elevation,pcpn,presentweather,alarmstatus,remarks,timestamp) "+
"values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
cmd.Parameters.Add("param1", UniDbType.VarChar).Value="300";
cmd.Parameters.Add("param2", UniDbType.VarChar).Value="02";
cmd.Parameters.Add("param3", UniDbType.VarChar).Value="N/A";
cmd.Parameters.Add("param4", UniDbType.VarChar).Value="N/A";
cmd.Parameters.Add("param5", UniDbType.VarChar).Value="12 (C)";
cmd.Parameters.Add("param6", UniDbType.VarChar).Value="14 (C)";
cmd.Parameters.Add("param7", UniDbType.VarChar).Value="12:41";
cmd.Parameters.Add("param8", UniDbType.VarChar).Value="11/22/33";
cmd.Parameters.Add("param9", UniDbType.VarChar).Value="N/A";
cmd.Parameters.Add("param10", UniDbType.VarChar).Value="N/A";
cmd.Parameters.Add("param11", UniDbType.VarChar).Value="N/A";
cmd.Parameters.Add("param12", UniDbType.VarChar).Value="N/A";
cmd.Parameters.Add("param13", UniDbType.VarChar).Value="N/A";
cmd.Parameters.Add("param14", UniDbType.VarChar).Value="N/A";
cmd.Parameters.Add("param15", UniDbType.VarChar).Value="N/A";
cmd.Parameters.Add("param16", UniDbType.VarChar).Value="N/A";
cmd.Parameters.Add("param17", UniDbType.VarChar).Value="N/A";
cmd.Parameters.Add("param18", UniDbType.VarChar).Value="N/A";
cmd.Parameters.Add("param19", UniDbType.VarChar).Value="N/A";
cmd.Parameters.Add("param20", UniDbType.VarChar).Value="N/A";
cmd.Parameters.Add("param21", UniDbType.VarChar).Value="N/A";
cmd.Parameters.Add("param22", UniDbType.VarChar).Value="N/A";

connection.Open();
cmd.ExecuteNonQuery();
connection.Close();
}
catch(Exception ee)
{
System.Diagnostics.Debug.WriteLine(ee);
}
}



Now, I created another project with just Unidirect on it and it worked fine with this code, I think it has to do with one of the other components loaded.

Please Help!!

-Troy
codemonkey2003
 
Posts: 1
Joined: Tue 27 Mar 2007 16:36

Postby Alexey » Wed 28 Mar 2007 05:43

Now, I created another project with just Unidirect on it and it worked fine with this code
What is the difference between two projects? Please describe in detail.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43


Return to dotConnect Universal