Connection string for ASP.NET aplication (language=VB)
Closed
mikeoe2003
Posts
24
Registration date
Thursday November 1, 2012
Status
Member
Last seen
March 27, 2014
-
Mar 24, 2014 at 02:35 PM
Blocked Profile - Mar 25, 2014 at 07:11 PM
Blocked Profile - Mar 25, 2014 at 07:11 PM
Related:
- Connection string for ASP.NET aplication (language=VB)
- "Winamp language pack" - Guide
- Idm language change - Guide
- How to change language in kmplayer - Guide
- Audacity change language - Guide
- Opera change language - Guide
3 responses
Ok, hang in there.
Here is the connections strings:
I HOPE THIS HELPS!
Have FUN!
Here is the connections strings:
<% dbsource="\\theserversetuff\wwwroot\someotherrootfolder\DATA\P1.mdb" strServername = LCase(Request.ServerVariables("SERVER_NAME")) Set conn = CreateObject("ADODB.CONNECTION") set rsdev = CreateObject("ADODB.recordset") strcxn="Provider=Microsoft.Jet.OLEDB.4.0;User ID=admin;Data Source=" & dbsource & ";Persist Security Info=False" conn.Open strcxn 'get the querystring into the DB STRRSdate = "SELECT * FROM tbl_contacts;" 'here is the magic- 'RSDEV is the recordset the connections streams to 'STRRSdate is the query string 'CONN is the connection to the DB '************************************ RSDEV.OPEN STRRSdate, CONN AD=0 DO WHILE NOT RSDEV.EOF 'says keep doiing as long as the RSDEV has a record RSDEV.MOVENEXT 'get the next record in the set LOOP 'restart the loop RSDEV.CLOSE 'ALWAYS CLOSE THE RECORDSET SET RSDEV=NOTHING 'ALWAYS SET THE RECORDSET TO NOTHING OR MEMORY LEAK conn.close ' ALWAY CLOSE THE DB CONNECTIONS FOR OTHER RESOURCES set conn = nothing 'ALWAYS DESTROY YOUR CONNECTIONS %>
I HOPE THIS HELPS!
Have FUN!
mikeoe2003
Posts
24
Registration date
Thursday November 1, 2012
Status
Member
Last seen
March 27, 2014
2
Mar 25, 2014 at 07:09 PM
Mar 25, 2014 at 07:09 PM
Thanks alot ac3mack, this was really informative to me. I tried out a few things on my own and below is my code
CODE
========================
Imports System.Data
Imports System.Data.SqlClient
Public Class Registration_Form
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
Try
Dim cmd As New SqlCommand("INSERT INTO Contacts (SurName,FirstName,Gender,Age,Email,Phone,Occupation,State_of_Residence,State_of_Origin,Date) VALUES (@Sname,@Fname,@Ggender,@Aage,@Eemail,@Pphone,@Ooccupation,@Rstate,@Ostate,@Ddate)", con)
cmd.Parameters.AddWithValue("@Sname", txtSurname)
cmd.Parameters.AddWithValue("@Fname", txtFirstname)
cmd.Parameters.AddWithValue("@Ggender", txtGender)
cmd.Parameters.AddWithValue("@Aage", txtAge)
cmd.Parameters.AddWithValue("@Eemail", txtEmail)
cmd.Parameters.AddWithValue("@Pphone", txtPhone)
cmd.Parameters.AddWithValue("@Ooccupation", txtoccupation)
cmd.Parameters.AddWithValue("@Rstate", txtResidence)
cmd.Parameters.AddWithValue("@Ostate", txtOrigin)
cmd.Parameters.AddWithValue("@Ddate", txtDate)
con.Open()
'Response.Write("Conection opened")
cmd.ExecuteNonQuery()
Catch ex As Exception
con.Close()
End Try
End Sub
End Class
=========================================
The error message i get when i try to insert data into the DB is below:
ERROR message
=========================
Server Error in '/' Application.
No mapping exists from object type System.Web.UI.WebControls.TextBox to a known managed provider native type.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: No mapping exists from object type System.Web.UI.WebControls.TextBox to a known managed provider native type.
Source Error:
Line 23: cmd.Parameters.AddWithValue("@Ostate", txtOrigin)
Line 24: cmd.Parameters.AddWithValue("@Ddate", txtDate)
Line 25: con.Open()
Line 26: 'Response.Write("Conection opened")
Line 27: cmd.ExecuteNonQuery()
Source File: C:\Users\MIKE ONYENMA\Documents\NPA_Web_Proposal\UnitedTest1\UnitedTest1\Registration_Form.aspx.vb Line: 25
CODE
========================
Imports System.Data
Imports System.Data.SqlClient
Public Class Registration_Form
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
Try
Dim cmd As New SqlCommand("INSERT INTO Contacts (SurName,FirstName,Gender,Age,Email,Phone,Occupation,State_of_Residence,State_of_Origin,Date) VALUES (@Sname,@Fname,@Ggender,@Aage,@Eemail,@Pphone,@Ooccupation,@Rstate,@Ostate,@Ddate)", con)
cmd.Parameters.AddWithValue("@Sname", txtSurname)
cmd.Parameters.AddWithValue("@Fname", txtFirstname)
cmd.Parameters.AddWithValue("@Ggender", txtGender)
cmd.Parameters.AddWithValue("@Aage", txtAge)
cmd.Parameters.AddWithValue("@Eemail", txtEmail)
cmd.Parameters.AddWithValue("@Pphone", txtPhone)
cmd.Parameters.AddWithValue("@Ooccupation", txtoccupation)
cmd.Parameters.AddWithValue("@Rstate", txtResidence)
cmd.Parameters.AddWithValue("@Ostate", txtOrigin)
cmd.Parameters.AddWithValue("@Ddate", txtDate)
con.Open()
'Response.Write("Conection opened")
cmd.ExecuteNonQuery()
Catch ex As Exception
con.Close()
End Try
End Sub
End Class
=========================================
The error message i get when i try to insert data into the DB is below:
ERROR message
=========================
Server Error in '/' Application.
No mapping exists from object type System.Web.UI.WebControls.TextBox to a known managed provider native type.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: No mapping exists from object type System.Web.UI.WebControls.TextBox to a known managed provider native type.
Source Error:
Line 23: cmd.Parameters.AddWithValue("@Ostate", txtOrigin)
Line 24: cmd.Parameters.AddWithValue("@Ddate", txtDate)
Line 25: con.Open()
Line 26: 'Response.Write("Conection opened")
Line 27: cmd.ExecuteNonQuery()
Source File: C:\Users\MIKE ONYENMA\Documents\NPA_Web_Proposal\UnitedTest1\UnitedTest1\Registration_Form.aspx.vb Line: 25