How to Insert String In To SQL Express Database Field

chiques

New member
Joined
Oct 22, 2013
Messages
3
Programming Experience
Beginner
Hello Community,

I currently has a cluster of example code that I would like to combine. My current challenge is inserting a string from my GPIB bus into my SQL Database field.

My working code looks something like this:
VB.NET:
Dim vpp1 As String
vpp1 = GpibDevice.ReadString()
MsgBox("Current Voltage is :" & vpp1)

I would like to insert the 'vpp1' string into my ch1 in my SQL Server. I have tried this (I have left some of the sql dbase code out):

VB.NET:
Connection.Open()
             Dim newRecord As DataRow = table.NewRow()
             newRecord("ch1") = vpp1
             table.Rows.Add(newrecord)
             Dim COMMAND As New SqlCommandBuilder(usersDataAdapter)
             usersDataAdapter.Update(channel1, "waveforms")
             channel1.Dispose()
             Connection.Close()


I am basing my code from Database: How to Save Data to a Database Using SQL Client - YouTube and the National Instrument 488.2 libraries.


I hope I didn't leave out too much code, I didn't want to make my post too cluttered.

Thanks for any help.
 
I suggest that you take a look at this:

Retrieving and Saving Data in Databases

If all you want to do is insert one record then get rid of the DataSet, etc. As you can see, the most appropriate code varies depending on the specific circumstances. There's an example there that shows how to use ExecuteNonQuery, which is the appropriate option in this case.
 
I suggest that you take a look at this:

Retrieving and Saving Data in Databases

If all you want to do is insert one record then get rid of the DataSet, etc. As you can see, the most appropriate code varies depending on the specific circumstances. There's an example there that shows how to use ExecuteNonQuery, which is the appropriate option in this case.

I appreciate the reference. I am a complete NOOB so, Unfortunately for me; since its not 'working code' I'm still lost. Are there any examples that you know of that insert the date and time into an SQL database every second? That would help me to understand how to make this work.
 
I suggest that you take a look at this:

Retrieving and Saving Data in Databases

If all you want to do is insert one record then get rid of the DataSet, etc. As you can see, the most appropriate code varies depending on the specific circumstances. There's an example there that shows how to use ExecuteNonQuery, which is the appropriate option in this case.

I was able to get it work. I was opening and closing the database incorrectly. Once I changed the code to "public" and made sure the sequence was correct, I now get the data from my BUS in to the SQL field.

Thank you,
 

Latest posts

Back
Top