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.
| 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 andreturns 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 SubEnd ClassIt 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 StringBad me.Thanks for reading my post anywayIt is better to be prepared and not have an opportunity than to not be prepared and have an opportunity |
 |
|
|
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 andreturns 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 SubEnd ClassIt is better to be prepared and not have an opportunity than to not be prepared and have an opportunity
Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
nomadsoul
Yak Posting Veteran
89 Posts |
Posted - 2007-05-30 : 09:30:23
|
| Thanks Harsh for your replyIt is better to be prepared and not have an opportunity than to not be prepared and have an opportunity |
 |
|
|
|
|
|
|
|