T
Titanium man11
Guest
hello;
Im working with database using Access;
I connect the access database from the properties to the form.
Im using this code to add information from my form to the access table:
Dim objconnection As SqlConnection = New SqlConnection("server=localhost;Database=Items;User id=Admin;password=")
Dim objcommand As SqlCommand = New SqlCommand
objcommand.Connection = objconnection
objcommand.CommandText = "INSERT INTO Table" & _
"(ID,name,age,school)" & "VALUES(@ID,@name,@age,@school)"
objcommand.Parameters.AddWithValue("@ID", max.ToString)
objcommand.Parameters.AddWithValue("@name", txt_name.Text)
objcommand.Parameters.AddWithValue("@age", txt_age.Text)
objcommand.Parameters.AddWithValue("@school", txt_school)
objconnection.Open()
objcommand.ExecuteNonQuery()
objconnection.Close()
But the problem is whenever its activated ,an error appears on the objcommand.open,that displays:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
So what is the problem and its solution.
Continue reading...
Im working with database using Access;
I connect the access database from the properties to the form.
Im using this code to add information from my form to the access table:
Dim objconnection As SqlConnection = New SqlConnection("server=localhost;Database=Items;User id=Admin;password=")
Dim objcommand As SqlCommand = New SqlCommand
objcommand.Connection = objconnection
objcommand.CommandText = "INSERT INTO Table" & _
"(ID,name,age,school)" & "VALUES(@ID,@name,@age,@school)"
objcommand.Parameters.AddWithValue("@ID", max.ToString)
objcommand.Parameters.AddWithValue("@name", txt_name.Text)
objcommand.Parameters.AddWithValue("@age", txt_age.Text)
objcommand.Parameters.AddWithValue("@school", txt_school)
objconnection.Open()
objcommand.ExecuteNonQuery()
objconnection.Close()
But the problem is whenever its activated ,an error appears on the objcommand.open,that displays:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
So what is the problem and its solution.
Continue reading...