Click here to Skip to main content
16,008,719 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralThe whole source code . Pin
rushing1-Feb-05 14:51
rushing1-Feb-05 14:51 
GeneralRe: The whole source code . Pin
Dave Kreskowiak1-Feb-05 17:59
mveDave Kreskowiak1-Feb-05 17:59 
GeneralSynchronize two databases Pin
Aman Ullah Principal Software Engineer31-Jan-05 21:00
Aman Ullah Principal Software Engineer31-Jan-05 21:00 
GeneralRe: Synchronize two databases Pin
Dave Kreskowiak1-Feb-05 3:43
mveDave Kreskowiak1-Feb-05 3:43 
GeneralSynchronize two database Pin
Aman Ullah Principal Software Engineer31-Jan-05 20:58
Aman Ullah Principal Software Engineer31-Jan-05 20:58 
GeneralPrinting in VB.net (Please Please help me) Pin
Aman Ullah Principal Software Engineer31-Jan-05 18:31
Aman Ullah Principal Software Engineer31-Jan-05 18:31 
GeneralRe: Printing in VB.net (Please Please help me) Pin
Dave Kreskowiak1-Feb-05 3:39
mveDave Kreskowiak1-Feb-05 3:39 
GeneralVB.Net and Access Stored Procedures Pin
BlueMurderJay31-Jan-05 16:44
BlueMurderJay31-Jan-05 16:44 
I have been killing myself with this and getting nowhere.

I have an Access DB with a table for clients, among others. I am trying to use a stored procedure (query) to insert a new client. Here is my code for this part:

Public Sub addCustomer()

'Grab the contents of each field
Dim CustNumVal As String = Me.tbxCustNum.Text
Dim CustNameVal As String = Me.cbxCustName.Text
Dim CustContactVal As String = Me.tbxCustContact.Text
Dim CustAdd1Val As String = Me.tbxCustAdd1.Text
Dim CustAdd2Val As String = Me.tbxCustAdd2.Text
Dim CustCityVal As String = Me.tbxCustCity.Text
Dim CustStateVal As String = Me.tbxCustState.Text
Dim CustZipVal As String = Me.tbxCustZip.Text
Dim CustPhoneVal As String = Me.tbxCustPhone.Text
Dim CustFaxVal As String = Me.tbxcustFax.Text
Dim CustEmailVal As String = Me.tbxCustEmail.Text

'Create Command Params
objCommand = New OleDb.OleDbCommand
objCommand.Connection = objConnection
objCommand.CommandType = CommandType.StoredProcedure
objCommand.Parameters.Add("@CustNum", OleDb.OleDbType.Integer, 50, CustNumVal)
objCommand.Parameters.Add("@CustName", OleDb.OleDbType.Char, 50, CustNameVal)
objCommand.Parameters.Add("@CustContact", OleDb.OleDbType.Char, 50, CustContactVal)
objCommand.Parameters.Add("@CustAdd1", OleDb.OleDbType.Char, 50, CustAdd1Val)
objCommand.Parameters.Add("@CustAdd2", OleDb.OleDbType.Char, 50, CustAdd2Val)
objCommand.Parameters.Add("@CustCity", OleDb.OleDbType.Char, 2, CustCityVal)
objCommand.Parameters.Add("@CustState", OleDb.OleDbType.Char, 60, CustStateVal)
objCommand.Parameters.Add("@CustZip", OleDb.OleDbType.Integer, 50, CustZipVal)
objCommand.Parameters.Add("@CustPhone", OleDb.OleDbType.Char, 50, CustPhoneVal)
objCommand.Parameters.Add("@CustFax", OleDb.OleDbType.Char, 50, CustFaxVal)
objCommand.Parameters.Add("@CustEmail", OleDb.OleDbType.VarChar, 50, CustEmailVal)

objCommand.CommandText = "EXECUTE usp_AddCustomer"
objConnection.Open()
objCommand.ExecuteNonQuery()
objConnection.Close()

'Change the style of the drop down list
Me.cbxCustName.DropDownStyle = ComboBoxStyle.DropDownList

'Revert the controls back to read only
Me.tbxCustAdd1.ReadOnly = True
Me.tbxCustAdd2.ReadOnly = True
Me.tbxCustCity.ReadOnly = True
Me.tbxCustContact.ReadOnly = True
Me.tbxCustEmail.ReadOnly = True
Me.tbxCustNum.ReadOnly = True
Me.tbxCustPhone.ReadOnly = True
Me.tbxcustFax.ReadOnly = True
Me.tbxCustState.ReadOnly = True
Me.tbxCustZip.ReadOnly = True

'Hide the buttons
Me.btnAction.Visible = False
Me.btnCancelNew.Visible = False

'Clear and fill the Data Set
DsCustInfo.Clear()
daCustInfo.Fill(DsCustInfo)

'Set the record number to the new record
Dim newRecID As Integer
newRecID = Me.BindingContext(DsCustInfo, "custinfo").Count
Me.BindingContext(DsCustInfo, "custinfo").Position = newRecID

'Cleanup
CustNumVal = Nothing
CustNameVal = Nothing
CustContactVal = Nothing
CustAdd1Val = Nothing
CustAdd2Val = Nothing
CustCityVal = Nothing
CustStateVal = Nothing
CustZipVal = Nothing
CustPhoneVal = Nothing
CustFaxVal = Nothing
CustEmailVal = Nothing
objConnection.Close()

End Sub

The variables, strConnectionString, objConnection and objCommand are delcared at the top of the form as global variables as such:

Inherits System.Windows.Forms.Form
Public strConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\user\My Documents\Visual Studio Projects\" & _
"OnBase Configurator\db1.mdb;"
Public objConnection As New OleDb.OleDbConnection(strConnectionString)
Public objCommand As New OleDb.OleDbCommand

No matter what I do, I keep getting the following error:

An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll

Someone please help me or shoot me. Either one is fine right now.

Jay Davis
GeneralRe: VB.Net and Access Stored Procedures Pin
Just Greeky Creek1-Feb-05 1:41
Just Greeky Creek1-Feb-05 1:41 
GeneralRe: VB.Net and Access Stored Procedures Pin
BlueMurderJay1-Feb-05 14:39
BlueMurderJay1-Feb-05 14:39 
GeneralRe: VB.Net and Access Stored Procedures Pin
BlueMurderJay1-Feb-05 14:44
BlueMurderJay1-Feb-05 14:44 
GeneralRe: VB.Net and Access Stored Procedures Pin
BlueMurderJay1-Feb-05 16:11
BlueMurderJay1-Feb-05 16:11 
GeneralRe: VB.Net and Access Stored Procedures Pin
Dave Kreskowiak1-Feb-05 18:06
mveDave Kreskowiak1-Feb-05 18:06 
QuestionHow to use DirectShow in VB.net? Pin
rushing31-Jan-05 14:32
rushing31-Jan-05 14:32 
AnswerRe: How to use DirectShow in VB.net? Pin
Christian Graus31-Jan-05 14:58
protectorChristian Graus31-Jan-05 14:58 
Generalcrystal reports - dynamically add detail section Pin
kkristian31-Jan-05 11:48
kkristian31-Jan-05 11:48 
QuestionCan someone help me with this one Pin
Delo31-Jan-05 11:39
Delo31-Jan-05 11:39 
AnswerRe: Can someone help me with this one Pin
Charlie Williams31-Jan-05 12:38
Charlie Williams31-Jan-05 12:38 
GeneralRe: Can someone help me with this one Pin
Delo31-Jan-05 12:56
Delo31-Jan-05 12:56 
GeneralRe: Can someone help me with this one Pin
rwestgraham31-Jan-05 14:36
rwestgraham31-Jan-05 14:36 
GeneralRe: Can someone help me with this one Pin
Delo31-Jan-05 14:57
Delo31-Jan-05 14:57 
Questionhow to handle a change on a runtime combobox value to enable the OKbutton Pin
David M J31-Jan-05 10:45
David M J31-Jan-05 10:45 
AnswerRe: how to handle a change on a runtime combobox value to enable the OKbutton Pin
rwestgraham31-Jan-05 12:34
rwestgraham31-Jan-05 12:34 
GeneralRecordset Object in VB.net Pin
eshban28431-Jan-05 10:27
eshban28431-Jan-05 10:27 
GeneralRe: Recordset Object in VB.net Pin
Dave Kreskowiak1-Feb-05 3:33
mveDave Kreskowiak1-Feb-05 3:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.