Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > SQL Connection
 

SQL Connection

I'm really baffled by this one. I'mreally new to windows forms, my experience is with web forms. But . . . I've managed to design and deploy a project. It works great on my machine. I can connect to SQL, update table, do some file manipulations, and send an email.

I deploy it to the machine where I want it to run. And it does the file manipulations and sends the email - but no table updates. The connection string is in the app.config.

I get no errors. Nothing. I've built an ODBC connection on the machineand ittests fine. Nothing in the event viewer either on the workstation or the sql server. Here's the snipet of code. Can anyone guide me on what I'm doing wrong?
<add name="TAM.Translation.My.MySettings.Portal" connectionString="Data Source=mysqlserver;Initial Catalog=Portal;User ID=myuser;Password=mypwd" providerName="System.Data.SqlClient"/>

Try

Dim command1 As New SqlCommand("mystoredprocedurename")
command1.CommandType = CommandType.StoredProcedure

'Initiate connection to SQL source

Dim connection As New SqlConnection(My.Settings.Portal)
command1.Connection = connection
connection.Open()
command1.Parameters.AddWithValue("@SID", SID)
command1.ExecuteNonQuery()

connection.Close()

Catch ex As SqlException
DisplaySqlErrors(ex) ---------This traps nothing!
End Try

GirlNet  Wednesday, September 30, 2009 9:03 PM

Hi GirlNet,

 

Could you please answer the questions below:

1.    Where is the database, together with the application?

2.    How did you deploy the application and database?

From my experience, the root cause is mostly about the connection string. You can write a small program which connects to database with the same connection string and test it to see if it works.

Regards,
Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
  • Marked As Answer byGirlNet Friday, October 02, 2009 8:38 PM
  •  
Aland Li  Friday, October 02, 2009 9:21 AM
FINALLY!  After reading Aland Li's post, I went back and created a new connection string, rebuilt it and it WORKS! (Breathe heavy sigh of relief).

He's the only thing that is different in the new connection string -

 

Persist Security Info=True
Thanks very much!
GirlNet  Friday, October 02, 2009 8:38 PM

Hi GirlNet,

 

Could you please answer the questions below:

1.    Where is the database, together with the application?

2.    How did you deploy the application and database?

From my experience, the root cause is mostly about the connection string. You can write a small program which connects to database with the same connection string and test it to see if it works.

Regards,
Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
  • Marked As Answer byGirlNet Friday, October 02, 2009 8:38 PM
  •  
Aland Li  Friday, October 02, 2009 9:21 AM
The database is remote - so not within the application.  The release version is installed on the sql server.  To test it, I have tried the installation on 3 different machines now - and it works fine everytime . . . .except for the machine I need it to be on.

How are the permissions defined for windows app?  Does it take the logged in user to connect?  Or does it use the user defined in the connection string?

It would be great if I can an error to troubleshoot - but I get nothing.

Thanks for any help!
GirlNet  Friday, October 02, 2009 8:20 PM
FINALLY!  After reading Aland Li's post, I went back and created a new connection string, rebuilt it and it WORKS! (Breathe heavy sigh of relief).

He's the only thing that is different in the new connection string -

 

Persist Security Info=True
Thanks very much!
GirlNet  Friday, October 02, 2009 8:38 PM

You can use google to search for other answers

Custom Search

More Threads

• Binding the Image attribute of a PictureBox
• change an image in unbound image column in datagridview
• Column Expressions not accepting static methods?
• Insert the Item to ComboBox after databinding
• Bind DataGrid CaptionText
• Datagridview Filter
• Right Click Pop Up Box on a Datagridview
• read data from RS232 in C# windows
• Problem with Custom Calender(EditingControl) in Datagridview
• Handling concurrency with table adapter manager