Hi
I have uptil now only used the WYSIWYG for retrieving info from my DB, but now i want to insert some information to the DB in a sub.
My connectionstring is in web.config and is as follows
How do i connect to this connectionstring from inside a sub?<connectionStrings> <add name="shopConnectionString" connectionString="Data Source=IP.ADRESS.GOES.HERE;Initial Catalog=shop;Persist Security Info=True;User ID=MyId;Password=********" providerName="System.Data.SqlClient" /> </connectionStrings>
ConfigurationManager.ConnectionStrings["shopConnectionString"].ConnectionString
|||Ok
Could you be a bit more specific?
for example
Sub add_click'connect to the DB' Execute SQL, for example: INSERT INTO table1 SELECT * FROM table2'close the connectionEnd Sub
That would be great, if you could help me with that.
Dim scon as SqlConnecrion =new SqlConnection( ConfigurationManager.ConnectionStrings["shopConnectionString"].ConnectionString )
use this sql Connecton
|||i'm getting an error "identifier expected"
Dim MyConn as SqlConnection =new SqlConnection( ConfigurationManager.ConnectionStrings["'<--errormessageWhat could be wrong?|||
http://www.dotnetfun.com/articles/framework/2.0/WhatsNew20ConfigurationManager.aspx
See the tutorial to use the same and see where ur doing wrong
|||Solved it!
Here's what worked for me.
Dim connAs SqlConnection conn =New SqlConnection(ConfigurationManager.ConnectionStrings("shopConnectionString").ConnectionString)
/jonas
No comments:
Post a Comment