Question:
Connecting VB.net to a Microsoft SQL Server database - what am I doing wrong ?
Jane C
2008-02-24 09:38:16 UTC
I'm putting together a VB 2005 Express Edition application which use the built-in Microsoft SQL server to store data.

I've got my code almost working but it's not putting the data into the database (and it's not giving me any errors either)

Here's the code.

Dim da As New FrameworkDataSetTableAdapters.ProjectsTableAdapter()

Dim projects As FrameworkDataSet.ProjectsDataTable = da.GetData()
Dim row As FrameworkDataSet.ProjectsRow

row = projects.NewProjectsRow()

row.projectName = "Missing-Auctions.com"
row.linkText = "Missing-Auctions.com"
row.url = "http://www.missing-auctions.com"
row.description = "Find misspelled eBay auctions"
row.keywords = "ebay typos, auction typos"
row.name = "Missing Auctions"
row.email = "info@missing-auctions.com"

projects.AddProjectsRow(row)
projects.AcceptChanges()

Note that there's a ProjectID column in the table as well which is the table key.

So, what am I doing wrong ?
Three answers:
Lapband Man
2008-02-24 11:02:14 UTC
You have to set up a connection string to access any database.
Big Dave
2008-02-24 09:47:38 UTC
I am no VB expert but I cannot see a connection string to the database defined anywhere....maybe that will help
?
2016-05-23 07:18:35 UTC
Better u write a file handelling code.Which accesses SQLDMO object to stop server & allow u take a backup otherwise u mannually stop server then goto sql directory then data copy paste .mdf *& .LDF file & add it to archive


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...