If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > how to insert and retrieve data from .mdf file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-10-11, 04:55
suhailtholakkal suhailtholakkal is offline
Registered User
 
Join Date: Dec 2011
Posts: 2
how to insert and retrieve data from .mdf file

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
Reply With Quote
  #2 (permalink)  
Old 12-10-11, 11:25
randirsa randirsa is offline
Registered User
 
Join Date: Nov 2011
Posts: 21
Can you post the error message?
Reply With Quote
Reply

Tags
asp.net, sql server 2008, vb.net

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On