i want to use sql server as a back end for my asp.net shopping cart using
vb.net..i have created an "news.mdf" under app_data folder of my website in visual studio2010...but i tried to connect it to database using below command
..but showing error...
sqlconnectionstring = "Data Source=.\SQLEXPRESS;attachdbfilename=\App_Data\myd atabase_data.mdf;Integrated Security=true;User Instance=true"
myconnection.ConnectionString = sqlconnectionstring
insertstring = "insert into News_table values(@N_head,@n_contents); "
mycommand = New SqlCommand(insertstring, myconnection)
mycommand.Parameters.Add(New SqlParameter("@N_head", SqlDbType.NVarChar, 1000))
mycommand.Parameters("@N_head").Value = nh_t.Text
mycommand.Parameters.Add(New SqlParameter("@n_contents", SqlDbType.Text, 4000))
mycommand.Parameters("@n_contents").Value = nc_ta.Value
Try
mycommand.ExecuteNonQuery()
MsgBox("news added successfully")
myconnection.Close()
Catch ex As Exception
MsgBox("insertion failed")
End Try
please guide me to fix this error..and how to display this data in my site also