Solved

Insert Multiple Variables into the same SQL Data field

Posted on 2004-09-23
3
192 Views
Last Modified: 2010-04-23
Hello Experts!

I am still new to Visual Basic.NET, and I have seemed to run into an obstacle I can readily solve.  Here is what I am trying to do.  I am writing a custom record insertion form to generate hyperlinks and insert them in to a Database table Data field.  The content of the hyperlinks need to be based on user input.

For example: <a href=http://server/[user input from textbox1]/[more user input from textbox2].pdf>[Display Text from textbox3]</a>

I have been able to insert into the target data field from a textbox a which the user has input information, and assigned it to a button to load and return the newly inserted data, however I need the whole hyperlink to be inserted into the same target data field.

I have tried to add variables in between the single quotes required to define a variable in a sql statement with the “&” and the “+”.  At design time Visual Basic does not have a problem with it, but a run time it fails.

Does anybody know of an effective way to accomplish this?  I need the whole hyperlink to insert into the target data field.


Here is the code I have so far:


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim dataset1 As New DataSet
        dataset1 = New DataSet("dataset1")

        Dim ConnectionString As String = "Provider=SQLOLEDB.1;Integrated Security=SSPI;data sourc" & _
        "e=LOGSOHFIL01;persist security info=False;initial catalog=MasterFileIndex"

        Dim Connection1 As OleDbConnection = New OleDbConnection(ConnectionString)

        Dim Command1 As OleDbCommand = _
        New OleDbCommand("INSERT INTO test (First_Name, Last_Name, Info) values ('" & TextBox1.Text & "  ', ' " & TextBox2.Text & " ', '" & TextBox3.Text & "') select* FROM test")
        Command1.CommandType = CommandType.Text

        Connection1.Open()
        Command1.Connection = Connection1

        Dim OleDbDataAdapter1 As OleDbDataAdapter = New OleDbDataAdapter

        OleDbDataAdapter1.SelectCommand = Command1
        OleDbDataAdapter1.Fill(dataset1, "authors")

        DataGrid1.SetDataBinding(dataset1, "authors")
        Connection1.Close()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class


Thanks for your help!
0
Comment
Question by:ndegioia
3 Comments
 
LVL 4

Author Comment

by:ndegioia
ID: 12179541
I found my own answer:)  All i had to do was to write the collect all of the data and place the rest of the HTML for the hyperlink code into one variable and send it to sql.

0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12376741
PAQed, with points refunded (50)

Computer101
E-E Admin
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now