Tuesday, March 27, 2012

General connection to SQL Server... done... grids and data retrival ...ugghhh

Help!!! please!!!... I'm pulling my hair off... Having an external hosting for sql server is terrible for .net. Too many restrictions and they are not willing to help at all... I cannot connect directly, I have to do everything using strings. Honestly and it's a shame to admit it I never learned how to connect using strings, only using the wizard (upsizing DBs from Access to SQL Server)finally, after a month of trying I was able to connect to the database using a string like this:
Dim CS As String
Dim db_name, db_username, db_userpassword As String
Dim db_server As String

db_server = "blah,blah,secureserver.net" /yes, with them >:(
db_name = "DB##"
db_username = "***"
db_userpassword = "***"


Me.SqlConnection1.ConnectionString = "SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PWD=" & db_userpassword

I am probably not using it right but it's working to capture info using stored procedures but I've been trying to get my datagrids to connect and they are impossible... Any ideas? what would be the coding part of the datagrid/dataset/etc... connection? That probably means that I can't use the property builder or the dataset generator, right? Any ideas ? Thanks

(using 1.1 Framework)

I hope you are not doing this in every page? Tomorrow if you need to change hosting companies you dont want to go through all the pain you are now going through again, do you? You might want to put the connection string in web.config file and use the connection string all over your app. So even if you need to point the server to a different machine, its just one line you need to change and your app can remain as is.

Regarding code snippets for datagrid/dataset check out articles at 4guysfromrolla.com. They have an extensive series of articles on datagrids. Besides you can always google for specific issues.

sql

No comments:

Post a Comment