Friday, March 30, 2012

Ms SQL7 linking problem

i have tried linking all my aspx scripts with ms access, they all worked,now i have switched on to ms sql7...iam not familier with the codes used for sql...my main problem is the data source syntax...in case of access i had given the file address along with extension...eg: C:\Data\Nortwind.mdb...so what should i do in case of sql... i have also given my code below

sub Page_load(sender as object, E as eventargs)

dim objconnection As sqlconnection
dim objcommand as sqlCommand
dim objadapter as sqlDataAdapter
dim objdata As DataSet
dim strsearch as String
dim sqlquery as String

strsearch = tb1.text

if Len(trim(strSearch))>0 then

objConnection = new sqlconnection("Data Source=(localhost);")

sqlquery= "select * from mayank where (name"&strsearch.ToString()&")"

objcommand = new sqlcommand(sqlquery, objconnection)

objadapter = new sqlDataAdapter(objcommand)

objdata = new DataSet()
objadapter.Fill(objdata)

DataGrid1.DataSource = objdata

DataGrid1.DataBind()

objConnection.close

Else
tb1.text= "enter your search here"
end if
end sub


Checkwww.connectionstrings.com

Regards

No comments:

Post a Comment