|
-
May 3rd, 2004, 11:05 AM
#1
Thread Starter
New Member
update sql
I am trying to update my SQL database. With this code it will not work if I want to pass it the text from a textbox. If I set
Dim outgoingpath As String = TextBox1.Text
it does not work... if I do this instead
Dim outgoingpath As String = "test"
it works. Is there something special I have to do to the textbox to make it work? Thanks.
Dim PathInfo As String
PathInfo = Request.QueryString("OutGoingPath")
Dim strConnection As String
Dim outgoingpath As String = TextBox1.Text
strConnection = "data source=jwallace;initial catalog=Jt;password=testadmin;persist security info=True;user id=Julie;workstation id=Jw;"
Dim mySelectQuery As String = "UPDATE Gateway SET OutGoingPath = '" & outgoingpath & "' WHERE OutGoingPath= '" & PathInfo & "' "
Dim myConnection As New SqlConnection(strConnection)
Dim myCommand As New SqlCommand(mySelectQuery, myConnection)
myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()
-
May 3rd, 2004, 11:21 AM
#2
Dimming a variable this way is like dimming a Const. You can not
dimension a Constant with a variable value. Defeats the purpose
of a Constant.
VB Code:
Dim outgoingpath As String = TextBox1.Text
Just Dim the variable and in the Form_Load or Sub Main
procedure set the value of the variable to the textbox.
VB Code:
Private Sub Form_Load()
Dim outgoingpath As String
outgoingpath = TextBox1.Text
'...
'...
'...
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|