I dont know what the Ole DB Services=-4; means i have looked through the beginners guide to asp.net
vb.net 2003 and it seems to be in every connection string. i have tried to find somewhere in the book that breaks a connection string down and explains it but i cant find one. That is the only change i made to the web.config and the following is the new code for the params that you suggested to cut down on code. By style i meant this new cut down code (Sorry for the confusion).
<%@ Page Language="
VB" Debug="true" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
Sub Page_Load()
DropCountryList1.DataSource = CountriesList
DropCountryList1.DataBind()
DropCountryList2.DataSource = CountriesList
DropCountryList2.DataBind()
End Sub
' This will retrieves the countries from the databse
Function CountriesList() As System.Data.IDataReader
Dim connectionString As String = ConfigurationSettings.AppSettings("connectionstrin g")
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection("connectionstrin g")
Dim queryString As String = "SELECT [Countries].[locName] FROM [Countries]"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
dbConnection.Open
Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
Return dataReader
End Function
' This is the submit button that will send all the information to the database
Sub BtnSubmit_Click (sender as object, e as eventargs)
Dim connectionString as string = ConfigurationSettings.AppSettings("connectionstrin g")
Dim dbConnection As New OleDbConnection("connectionstring")
dbConnection.Open()
Dim commandString as string = "INSERT INTO User_Details (B_First_Name, B_Last_Name, B_Add_1, B_Add_2, B_Town, B_PostCode, B_Country, B_Phone, S_First_Name, S_Last_Name, S_Add_1, S_Add_2, S_Town, S_PostCode, S_Country, S_Phone, User_Name, Password, Email, News_Opt_In) Values(@B_First_Name, @B_Last_Name, @B_Add_1, @B_Add_2, @B_Town, @B_PostCode, @B_Country, @B_Phone, @S_First_Name, @S_Last_Name, @S_Add_1, @S_Add_2, @S_Town, @S_PostCode, @S_Country, @S_Phone, @User_Name, @Password, @Email, @News_Opt_In)"
Dim dbCommand as new OleDbCommand(commandString, dbConnection)
dbCommand.Parameters.Add("@B_First_Name", OleDbType.VarChar, 10).Value = txtBFirstName.Text
dbCommand.Parameters.Add("@B_Last_Name", OleDbType.VarChar, 10).Value = txtBLastName.Text
dbCommand.Parameters.Add("@B_Add_1", OleDbType.VarChar, 15).Value = txtBAdd1.Text
dbCommand.Parameters.Add("@B_Add_2", OleDbType.VarChar, 15).Value = txtBAdd2.Text
dbCommand.Parameters.Add("@B_Town", OleDbType.VarChar, 10).Value = txtBTown.Text
dbCommand.Parameters.Add("@B_PostCode", OleDbType.VarChar, 10).Value = txtBPostCode.Text
dbCommand.Parameters.Add("@B_Country", OleDbType.VarChar, 15).Value = DropCountryList1.SelectedItem
dbCommand.Parameters.Add("@B_Phone", OleDbType.VarChar, 15).Value = txtBPhone.Text
dbCommand.Parameters.Add("@S_First_Name", OleDbType.VarChar, 10).Value = txtSFirstName.Text
dbCommand.Parameters.Add("@S_Last_Name", OleDbType.VarChar, 10).Value = txtSLastName.Text
dbCommand.Parameters.Add("@S_Add_1", OleDbType.VarChar, 15).Value = txtSAdd1.Text
dbCommand.Parameters.Add("@S_Add_2", OleDbType.VarChar, 15).Value = txtSAdd2.Text
dbCommand.Parameters.Add("@S_Town", OleDbType.VarChar, 10).Value = txtSTown.Text
dbCommand.Parameters.Add("@S_PostCode", OleDbType.VarChar, 10).Value = txtSPostCode.Text
dbCommand.Parameters.Add("@S_Country", OleDbType.VarChar, 15).Value = DropCountryList2.SelectedItem
dbCommand.Parameters.Add("@S_Phone", OleDbType.VarChar, 15).Value = txtSPhone.Text
dbCommand.Parameters.Add("@User_Name", OleDbType.VarChar, 15).Value = txtUserName.Text
dbCommand.Parameters.Add("@Email", OleDbType.VarChar, 15).Value = txtEmail.Text
dbCommand.Parameters.Add("@News_Opt_In", OleDbType.VarChar, 15).Value = NewsOptIn.Checked
dbCommand.ExecuteNonQuery()
dbConnection.Close()
End Sub
</script>