Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 sqlConn from textbox question

Author  Topic 

nomadsoul
Yak Posting Veteran

89 Posts

Posted - 2007-05-29 : 08:02:18
Good day everyone at ST,

I'm making a text box on a form that when I type in the server name,
it will connect to whatever server I've typed onClick of button. But I'm getting a build error dialog box asking if I want to continue.
Thing is, when I click yes,to continue, the errors show but the program runs and
returns a 1 value. But the form does not show the text box, just the
button(as it was before I added the text box)
The error below tells me there is a closing ')' missing? I don't see where.
In the error panel this appears:
E:\vbnet\AdoExamples\Form1.vb(72): ')' expected.


Here is the code :



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ServerName = TextBox1.Text
MakeConnection(ServerName)

End Sub
Private Sub MakeConnection(ByVal ServerName as String
Dim sqlConn As New SqlClient.SqlConnection
sqlConn.ConnectionString = "SERVER=" & ServerName & ";DATABASE=pubs; Integrated Security = SSPI"
Try
sqlConn.Open()
Catch sqlError As Exception
MessageBox.Show(sqlError.Message, "Connection Error")
End Try
MessageBox.Show(sqlConn.State)
If sqlConn.State = 1 Then
Me.Text = "Welcome to ADO.NET!"
End If
End Sub
End Class

It is better to be prepared and not have an opportunity than to not be prepared and have an opportunity

nomadsoul
Yak Posting Veteran

89 Posts

Posted - 2007-05-29 : 08:05:10
Sorry I found it:
Private Sub MakeConnection(ByVal ServerName as String
Bad me.
Thanks for reading my post anyway

It is better to be prepared and not have an opportunity than to not be prepared and have an opportunity
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-29 : 08:06:40
quote:
Originally posted by nomadsoul

Good day everyone at ST,

I'm making a text box on a form that when I type in the server name,
it will connect to whatever server I've typed onClick of button. But I'm getting a build error dialog box asking if I want to continue.
Thing is, when I click yes,to continue, the errors show but the program runs and
returns a 1 value. But the form does not show the text box, just the
button(as it was before I added the text box)
The error below tells me there is a closing ')' missing? I don't see where.
In the error panel this appears:
E:\vbnet\AdoExamples\Form1.vb(72): ')' expected.


Here is the code :



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ServerName = TextBox1.Text
MakeConnection(ServerName)

End Sub
Private Sub MakeConnection(ByVal ServerName as String) 'Missing Parenthesis here !
Dim sqlConn As New SqlClient.SqlConnection
sqlConn.ConnectionString = "SERVER=" & ServerName & ";DATABASE=pubs; Integrated Security = SSPI"
Try
sqlConn.Open()
Catch sqlError As Exception
MessageBox.Show(sqlError.Message, "Connection Error")
End Try
MessageBox.Show(sqlConn.State)
If sqlConn.State = 1 Then
Me.Text = "Welcome to ADO.NET!"
End If
End Sub
End Class

It is better to be prepared and not have an opportunity than to not be prepared and have an opportunity



Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

nomadsoul
Yak Posting Veteran

89 Posts

Posted - 2007-05-30 : 09:30:23
Thanks Harsh for your reply

It is better to be prepared and not have an opportunity than to not be prepared and have an opportunity
Go to Top of Page
   

- Advertisement -