Link to home
Start Free TrialLog in
Avatar of lz7cjc
lz7cjc

asked on

Passing variables to a Stored Procedure from *.aspx

Hi
I have the following Sproc
Please can you tell me, from scratch (i.e opening the DB connection onwards) how i pass the parameters through to the Sproc

CREATE PROCEDURE proc_tblJob_Insert
    (
    @Jobname varchar(50),
    @ConsultantID int,
    @JobDescription varchar(50),
    @statusID int,
    @calldate datetime,
    @comments varchar(50)
)

let me know if you need any more of the Sproc

thanks
Nick
Avatar of Jeff Certain
Jeff Certain
Flag of United States of America image

** You need to Import System.Data.SQLClient for this to work...

Public Sub tblJob_Insert(jobName as string) ' Add the remainder of your parameters here
            Dim connection As SqlConnection = New SqlConnection("YourConnectionString")
            connection.Open
            'create a command...
            Dim command As SqlCommand = New SqlCommand("proc_tblJob_Insert", connection)
            command.CommandType = System.Data.CommandType.StoredProcedure
            'parameters...
            Dim jobNameParam As SqlParameter = command.Parameters.Add("@jobName", System.Data.SqlDbType.Varchar,50)
            jobNameParam.Value = jobName
           ' etc... add the remainder of your variables here
            'execute...
            command.ExecuteNonQuery
            'cleanup...
            command.Dispose
            connection.Close
End Sub
Avatar of lz7cjc
lz7cjc

ASKER

ah...
in that case it might be a little more complicated!
I am getting the variables from a form like this:

Sub Submit_Click(Sender as Object, E as EventArgs)
           GetNewJob(0)
           Row = ClassyDS.Tables("Job").NewRow
           Row.Item("jobtitle") = title.Text
           Row.Item("jobdescription") = description.Text
           Row.Item("salary") = salary.Text
           Row.Item("nextcall") = nextcall.Text
           Row.Item("statusid") = ddlstatus.selecteditem.value
           Row.Item("began") = beganDate.Text
   
           GetNewCall(0)
           Row = ClassyDS1.Tables("Call").NewRow
          ' Row.Item("companyid") = ddlcompany.selecteditem.value
           Row.Item("consultantID") = ddlperson.selecteditem.value
           Row.Item("callDate") = beganDate.Text
           Row.Item("Comments") = "Initiation Call"
           Row.Item("JobId") = GetNewJob(CoNumSent)
   
   
           ClassyDS.Tables("job").rows.add(row)
           Adapter.Update(ClassyDS, "job")
   
           ClassyDS1.Tables("call").rows.add(row)
           Adapter.Update(ClassyDS1, "call")
   
   
           If ClassyDS.HasErrors      then
               Message.Text = "there was a an error in submitting the person's details. " & _
               ClassyDS.Tables("job").Rows(0).Rowerror
   
           Else
               Message.text = "The person has been successfully entered"
               title.Enabled = False
               description.Enabled = False
               ddlcompany.Enabled = False
               salary.Enabled = False
               ddlperson.Enabled = False
               nextcall.Enabled = False
               ddlstatus.Enabled = False
               begandate.Enabled = False
   
           End if
   
       End Sub
   
         Sub GetNewJob(CoNumSent as Integer)
           SelectStatement = "Select * from tbl_job where jobid=" & CoNumSent
           ConnectString = "Provider=SQLOLEDB; UID=SA;PWD=hello; Data Source=(local); database=jobs;"
           Connect.ConnectionString = ConnectString
           Adapter.SelectCommand = new OLEDbCommand(SelectStatement, Connect)
           ClassyCB = New OLEDBCommandBuilder(Adapter)
           Adapter.Fill(ClassyDS, "job")
           Return CoNumSent
         End Sub
   
        Sub GetNewCall(CoNumSent as Integer)
           SelectStatement = "Select * from tbl_call where callid=" & CoNumSent
           ConnectString = "Provider=SQLOLEDB; UID=SA;PWD=hello; Data Source=(local); database=jobs;"
           Connect.ConnectionString = ConnectString
           Adapter.SelectCommand = new OLEDbCommand(SelectStatement, Connect)
           ClassyCB = New OLEDBCommandBuilder(Adapter)
           Adapter.Fill(ClassyDS1, "call")
         End Sub

so where would i put this code and how would i assign the variables?
thanks
At what stage do you want to call the INSERT sproc?
I'm also confused as to why you're using two dataset. You ought to be using only one dataset, and populating the tables within in it.
Avatar of lz7cjc

ASKER

probably because i am pretty much new to this and don't really know what i am doing! have just been hacking code together until i can get it to work...

I want to load the page with a form containing text boxes and some drop down lists. I then want to hit the submit button, grab the values, write them to the DB via the Sproc and then display the values greyed out on the page (the same page)

so i guess i want to insert onClick and replace the code that i have... so do i just replace everything in onClick?

thanks
This ought to do it for you... (notice ConnectString is now a constant)

Don't forget, you'll have to refresh (i.e. repopulate) the DataSet, if you want it to reflect what is currently in the database after the update. Alternately, you can add rows directly to the tables...

Private Const ConnectString As String = "Provider=SQLOLEDB; UID=SA;PWD=hello; Data Source=(local); database=jobs;"
      Sub Submit_Click(ByVal Sender As Object, ByVal E As EventArgs)
            Dim errorCode As String = tblJob_Insert(title.Text, ddlperson.selecteditem.value, description.Text, statusID, beganDate.Text, "Initiation Call")

            If errorCode.Length <> 0 Then
                  Message.Text = "there was a an error in submitting the person's details. " & _
                  errorCode

            Else
                  Message.text = "The person has been successfully entered"
                  title.Enabled = False
                  description.Enabled = False
                  ddlcompany.Enabled = False
                  salary.Enabled = False
                  ddlperson.Enabled = False
                  nextcall.Enabled = False
                  ddlstatus.Enabled = False
                  begandate.Enabled = False

            End If

      End Sub

      Private Function tblJob_Insert(ByVal jobName As String, ByVal consultantID As Integer, ByVal jobDescription As String, ByVal statusID As Integer, ByVal calldate As DateTime, ByVal comments As String) As String
            Try
                  Dim connection As New OleDb.OleDbConnection(ConnectString)
                  connection.Open()
                  'create a command...
                  Dim command As New OleDb.OleDbCommand("proc_tblJob_Insert", connection)
                  command.CommandType = System.Data.CommandType.StoredProcedure
                  'parameters...
                  Dim jobNameParam As OleDb.OleDbParameter = command.Parameters.Add("@jobName", OleDb.OleDbType.VarChar, 50)
                  jobNameParam.Value = jobName
                  Dim consultantIDParam As OleDb.OleDbParameter = command.Parameters.Add("@ConsultantID", OleDb.OleDbType.Integer)
                  consultantIDParam.Value = consultantID
                  Dim jobDescriptionParam As OleDb.OleDbParameter = command.Parameters.Add("@JobDescription", OleDb.OleDbType.VarChar, 50)
                  jobDescriptionParam.Value = jobDescription
                  Dim statusIDParam As OleDb.OleDbParameter = command.Parameters.Add("@statusID", OleDb.OleDbType.Integer)
                  statusIDParam.Value = statusID
                  Dim callDateParam As OleDb.OleDbParameter = command.Parameters.Add("@calldate", OleDb.OleDbType.DBTimeStamp)
                  callDateParam.Value = calldate
                  Dim commentsParam As OleDb.OleDbParameter = command.Parameters.Add("@comments", System.Data.SqlDbType.VarChar, 50)
                  commentsParam.Value = comments

                  ' etc... add the remainder of your variables here
                  'execute...
                  command.ExecuteNonQuery()
                  'cleanup...
                  command.Dispose()
                  connection.Close()
            Catch ex As Exception
                  tblJob_Insert = ex.Message
            End Try
      End Function
End Class
Avatar of lz7cjc

ASKER

:-) fantastic... thanks - i will cut and paste, fill in the missing bits and get back to you
Avatar of lz7cjc

ASKER

i get the following error:
BC30001: Statement is not valid in a namespace.
Line 239:        #End ExternalSource
Line 240:        
Line 241:        Public Sub New()
Line 242:            MyBase.New
Line 243:            Dim dependencies As System.Collections.ArrayList

I have the following namespaces:
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OLEDB" %>
<%@ import Namespace="System.Data.SqlClient" %>

thanks
You don't need SQLClient... I misread your first code.

Other than that... I'm not at all sure what is is objecting to. You'd need to either post all the code, or check the stack in the error message.
Avatar of lz7cjc

ASKER

this is all the info i have on the error:
this is the whole page...

<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OLEDB" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
           Private Const ConnectString As String = "Provider=SQLOLEDB; UID=SA;PWD=hello; Data Source=(local); database=jobs;"

           Dim SelectStatement As String
           Dim Connect as OLEDbConnection = New OLEDbConnection
           Dim Adapter as OLEDBDataAdapter = New OLEDbDataAdapter
           Dim ClassyCB As OLEDBCommandBuilder
           Dim ClassyDS As Dataset = New DataSet
           Dim ClassyDS1 As Dataset = New DataSet
           Dim Row as DataRow

    Sub Page_Load(Sender As Object, E As EventArgs)
           Dim ConnectToDatabase as new SQLConnection("UID=SA;PWD=hello; Data Source=(local); database=jobs;")
           Dim DataAdapterJob as new SQLDataAdapter("SELECT * FROM tbl_job",connecttodatabase)
           Dim DataAdapterCall as new SQLDataAdapter("SELECT * FROM tbl_call",connecttodatabase)
           Dim DDLAdapterCompany as new SQLDataAdapter("SELECT CompanyName, CompanyID FROM tbl_Company",connecttodatabase)
           Dim DDLAdapterPeople as new SQLDataAdapter("SELECT consultantID, firstName, lastName FROM tbl_people",connecttodatabase)
           Dim DDLAdapterStatus as new SQLDataAdapter("SELECT statusId, statusName FROM tbl_status",connecttodatabase)


           Dim Ds as new DataSet
           Dim Ds1 as new DataSet
           Dim Ds2 as new DataSet
           Dim Ds3 as new DataSet
           Dim Ds4 as new DataSet

           connecttodatabase.open
           DataAdapterJob.Fill(DS, "Job")
           DataAdapterCall.Fill(DS1, "Call")
           DDLAdapterCompany.Fill(DS2, "company")
           DDLAdapterPeople.Fill(DS3, "People")
           DDLAdapterStatus.Fill(DS4, "status")


           connecttodatabase.close

           JobGrid.Datasource = Ds.tables("job")
          'company.Datasource = Ds3.tables("Company")


          If Not IsPostBack Then

                 ddlcompany.DataSource = Ds2  '<--- (Dataset Name)
                 ddlcompany.DataMember = "company" '<--- (Table Name)
                 ddlcompany.DataTextField = "CompanyName" '<---    (Column Name)
                 ddlcompany.DataValueField = "companyid" '<--- (Column Name)

                 ddlperson.DataSource = Ds3  '<--- (Dataset Name)
                 ddlperson.DataMember = "People" '<--- (Table Name)
                 ddlperson.DataTextField = "lastname" '<---    (Column Name)
                 ddlperson.DataValueField = "consultantid" '<--- (Column Name)

                 ddlstatus.DataSource = Ds4  '<--- (Dataset Name)
                 ddlstatus.DataMember = "status" '<--- (Table Name)
                 ddlstatus.DataTextField = "statusName" '<---    (Column Name)
                 ddlstatus.DataValueField = "statusId" '<--- (Column Name)

               end if

      page.databind
      end sub

     Sub Submit_Click(ByVal Sender As Object, ByVal E As EventArgs)
          Dim errorCode As String = tblJob_Insert(title.Text, ddlperson.selecteditem.value, description.Text, ddlstatus.selecteditem.value, beganDate.Text, "Initiation Call")

          If errorCode.Length <> 0 Then
               Message.Text = "there was a an error in submitting the person's details. " & _
               errorCode

          Else
               Message.text = "The person has been successfully entered"
               title.Enabled = False
               description.Enabled = False
               ddlcompany.Enabled = False
               salary.Enabled = False
               ddlperson.Enabled = False
               nextcall.Enabled = False
               ddlstatus.Enabled = False
               begandate.Enabled = False

          End If

     End Sub

     Private Function tblJob_Insert(ByVal jobName As String, ByVal consultantID As Integer, ByVal jobDescription As String, ByVal statusid As Integer, ByVal calldate As DateTime, ByVal comments As String) As String
          Try
               Dim connection As New OleDb.OleDbConnection(ConnectString)
               connection.Open()
               'create a command...
               'tbl_job parameters
               Dim command As New OleDb.OleDbCommand("proc_tblJob_Insert", connection)
               command.CommandType = System.Data.CommandType.StoredProcedure
               'parameters...
               Dim jobNameParam As OleDb.OleDbParameter = command.Parameters.Add("@jobName", OleDb.OleDbType.VarChar, 50)
               jobNameParam.Value = title.text
               Dim jobDescriptionParam As OleDb.OleDbParameter = command.Parameters.Add("@JobDescription", OleDb.OleDbType.VarChar, 50)
               jobDescriptionParam.Value = description.Text
               Dim statusIDParam As OleDb.OleDbParameter = command.Parameters.Add("@statusID", OleDb.OleDbType.Integer)
               statusIDParam.Value = ddlstatus.selecteditem.value
               'tbl_call parameters
               Dim consultantIDParam As OleDb.OleDbParameter = command.Parameters.Add("@ConsultantID", OleDb.OleDbType.Integer)
               consultantIDParam.Value = ddlperson.selecteditem.value
               Dim callDateParam As OleDb.OleDbParameter = command.Parameters.Add("@calldate", OleDb.OleDbType.DBTimeStamp)
               callDateParam.Value = nextcall.Text
               Dim commentsParam As OleDb.OleDbParameter = command.Parameters.Add("@comments", System.Data.SqlDbType.VarChar, 50)
               commentsParam.Value = "initiation call"

               ' etc... add the remainder of your variables here
               'execute...
               command.ExecuteNonQuery()
               'cleanup...
               command.Dispose()
               connection.Close()
          Catch ex As Exception
               tblJob_Insert = ex.Message
          End Try
     End Function
End Class

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
            <asp:datagrid id="jobgrid" runat="server" CellSpacing="1" GridLines="None" CellPadding="3" BackColor="White" ForeColor="Black"></asp:datagrid>
        </p>
        <table>
            <tbody>
                <tr>
                    <td>
                        Job Title
                    </td>
                    <td>
                        <asp:textbox id="title" runat="server" columns="50"></asp:textbox>
                    </td>
                </tr>
                <tr>
                    <td>
                        Job Description
                    </td>
                    <td>
                        <asp:textbox id="description" runat="server" columns="50" textmode="multiline" rows="5"></asp:textbox>
                    </td>
                </tr>
                <tr>
                    <td>
                        Company
                    </td>
                    <td>
                        <asp:DropDownList id="ddlcompany" runat="server"></asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td>
                        Salary
                    </td>
                    <td>
                        <asp:textbox id="Salary" runat="server" columns="50"></asp:textbox>
                    </td>
                </tr>
                <tr>
                    <td>
                        Consultant Name
                    </td>
                    <td>
                        <asp:DropDownList id="ddlperson" runat="server"></asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td>
                        Next Call
                    </td>
                    <td>
                        <asp:textbox id="nextCall" runat="server" columns="10"></asp:textbox>
                    </td>
                </tr>
                <tr>
                    <td>
                        Status
                    </td>
                    <td>
                        <asp:DropDownList id="ddlStatus" runat="server"></asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td>
                        Began Date
                    </td>
                    <td>
                        <asp:textbox id="begandate" runat="server" columns="10"></asp:textbox>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:button id="submit" onclick="Submit_Click" runat="server" text="Add New Person"></asp:button>
                    </td>
                </tr>
                <!-- Insert content here -->
            </tbody>
        </table>
        <asp:Label id="message" runat="server" bold="true"></asp:Label>
    </form>
</body>
</html>

thanks
Avatar of lz7cjc

ASKER

i know i haven't included all the parameters yet - i just wanted to get it working first
thanks
Is your database SQL server or something else? If it's SQL Server, we should only be using SQLClient, not OLEDB. If it's anything else, we should only be using OLEDB, not SQLClient. However... there are both in your code.
Avatar of lz7cjc

ASKER

it is SQL Server
Okay... I've separated your HTML and VB code. (This is easy to amintain isf you're using Visual Studio...) The following code goes in your HTML page (yourFormName.aspx). You'll have to replace yourFormName and YourProjectName appropriately

<%@ Page Language="VB" Debug="true" Codebehind="Yourformname.aspx.vb" Inherits="**yourProjectName.yourFormName" %>
<HTML>
      <HEAD>
      </HEAD>
      <body>
            <form runat="server" ID="Form1">
                  <p>
                        <asp:datagrid id="jobgrid" runat="server" CellSpacing="1" GridLines="None" CellPadding="3" BackColor="White"
                              ForeColor="Black"></asp:datagrid>
                  </p>
                  <table>
                        <tbody>
                              <tr>
                                    <td>
                                          Job Title
                                    </td>
                                    <td>
                                          <asp:textbox id="title" runat="server" columns="50"></asp:textbox>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Job Description
                                    </td>
                                    <td>
                                          <asp:textbox id="description" runat="server" columns="50" textmode="multiline" rows="5"></asp:textbox>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Company
                                    </td>
                                    <td>
                                          <asp:DropDownList id="ddlcompany" runat="server"></asp:DropDownList>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Salary
                                    </td>
                                    <td>
                                          <asp:textbox id="Salary" runat="server" columns="50"></asp:textbox>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Consultant Name
                                    </td>
                                    <td>
                                          <asp:DropDownList id="ddlperson" runat="server"></asp:DropDownList>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Next Call
                                    </td>
                                    <td>
                                          <asp:textbox id="nextCall" runat="server" columns="10"></asp:textbox>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Status
                                    </td>
                                    <td>
                                          <asp:DropDownList id="ddlStatus" runat="server"></asp:DropDownList>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Began Date
                                    </td>
                                    <td>
                                          <asp:textbox id="begandate" runat="server" columns="10"></asp:textbox>
                                    </td>
                              </tr>
                              <tr>
                                    <td colspan="2">
                                          <asp:button id="submit" onclick="Submit_Click" runat="server" text="Add New Person"></asp:button>
                                    </td>
                              </tr>
                              <!-- Insert content here -->
                        </tbody>
                  </table>
                  <asp:Label id="message" runat="server" bold="true"></asp:Label>
            </form>
      </body>
</HTML>

This code goes in a file called YourPageName.aspx.vb

Imports System.Data.OleDb
Imports System.Data.sqlclient

Public Class YourFormName
      Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

      'This call is required by the Web Form Designer.
      <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

      End Sub
      Protected WithEvents jobgrid As System.Web.UI.WebControls.DataGrid
      Protected WithEvents title As System.Web.UI.WebControls.TextBox
      Protected WithEvents description As System.Web.UI.WebControls.TextBox
      Protected WithEvents ddlcompany As System.Web.UI.WebControls.DropDownList
      Protected WithEvents Salary As System.Web.UI.WebControls.TextBox
      Protected WithEvents ddlperson As System.Web.UI.WebControls.DropDownList
      Protected WithEvents nextCall As System.Web.UI.WebControls.TextBox
      Protected WithEvents ddlStatus As System.Web.UI.WebControls.DropDownList
      Protected WithEvents begandate As System.Web.UI.WebControls.TextBox
      Protected WithEvents submit As System.Web.UI.WebControls.Button
      Protected WithEvents message As System.Web.UI.WebControls.Label

      'NOTE: The following placeholder declaration is required by the Web Form Designer.
      'Do not delete or move it.
      Private designerPlaceholderDeclaration As System.Object

      Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
      End Sub

#End Region

      Private Const ConnectString As String = "Provider=SQLOLEDB; UID=SA;PWD=hello; Data Source=(local); database=jobs;"

      Dim SelectStatement As String
      Dim Connect As OLEDbConnection = New OLEDbConnection
      Dim Adapter As OLEDBDataAdapter = New OLEDbDataAdapter
      Dim ClassyCB As OLEDBCommandBuilder
      Dim ClassyDS As DataSet = New DataSet
      Dim ClassyDS1 As DataSet = New DataSet
      Dim Row As DataRow

      Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
            Dim ConnectToDatabase As New SQLConnection("UID=SA;PWD=hello; Data Source=(local); database=jobs;")
            Dim DataAdapterJob As New SQLDataAdapter("SELECT * FROM tbl_job", ConnectToDatabase)
            Dim DataAdapterCall As New SQLDataAdapter("SELECT * FROM tbl_call", ConnectToDatabase)
            Dim DDLAdapterCompany As New SQLDataAdapter("SELECT CompanyName, CompanyID FROM tbl_Company", ConnectToDatabase)
            Dim DDLAdapterPeople As New SQLDataAdapter("SELECT consultantID, firstName, lastName FROM tbl_people", ConnectToDatabase)
            Dim DDLAdapterStatus As New SQLDataAdapter("SELECT statusId, statusName FROM tbl_status", ConnectToDatabase)


            Dim Ds As New DataSet
            Dim Ds1 As New DataSet
            Dim Ds2 As New DataSet
            Dim Ds3 As New DataSet
            Dim Ds4 As New DataSet

            ConnectToDatabase.open()
            DataAdapterJob.Fill(Ds, "Job")
            DataAdapterCall.Fill(Ds1, "Call")
            DDLAdapterCompany.Fill(Ds2, "company")
            DDLAdapterPeople.Fill(Ds3, "People")
            DDLAdapterStatus.Fill(Ds4, "status")


            ConnectToDatabase.close()

            jobgrid.DataSource = Ds.Tables("job")
            'company.Datasource = Ds3.tables("Company")


            If Not IsPostBack Then

                  ddlcompany.DataSource = Ds2                  '<--- (Dataset Name)
                  ddlcompany.DataMember = "company"             '<--- (Table Name)
                  ddlcompany.DataTextField = "CompanyName"             '<---    (Column Name)
                  ddlcompany.DataValueField = "companyid"             '<--- (Column Name)

                  ddlperson.DataSource = Ds3                  '<--- (Dataset Name)
                  ddlperson.DataMember = "People"             '<--- (Table Name)
                  ddlperson.DataTextField = "lastname"             '<---    (Column Name)
                  ddlperson.DataValueField = "consultantid"             '<--- (Column Name)

                  ddlStatus.DataSource = Ds4                  '<--- (Dataset Name)
                  ddlStatus.DataMember = "status"             '<--- (Table Name)
                  ddlStatus.DataTextField = "statusName"             '<---    (Column Name)
                  ddlStatus.DataValueField = "statusId"             '<--- (Column Name)

            End If

            Page.DataBind()
      End Sub

      Sub Submit_Click(ByVal Sender As Object, ByVal E As EventArgs)
            Dim errorCode As String = tblJob_Insert(title.Text, ddlperson.SelectedItem.Value, description.Text, ddlStatus.SelectedItem.Value, begandate.Text, "Initiation Call")

            If errorCode.Length <> 0 Then
                  message.Text = "there was a an error in submitting the person's details. " & _
                  errorCode

            Else
                  message.Text = "The person has been successfully entered"
                  title.Enabled = False
                  description.Enabled = False
                  ddlcompany.Enabled = False
                  Salary.Enabled = False
                  ddlperson.Enabled = False
                  nextCall.Enabled = False
                  ddlStatus.Enabled = False
                  begandate.Enabled = False

            End If

      End Sub

      Private Function tblJob_Insert(ByVal jobName As String, ByVal consultantID As Integer, ByVal jobDescription As String, ByVal statusid As Integer, ByVal calldate As DateTime, ByVal comments As String) As String
            Try
                  Dim connection As New OleDb.OleDbConnection(ConnectString)
                  connection.Open()
                  'create a command...
                  'tbl_job parameters
                  Dim command As New OleDb.OleDbCommand("proc_tblJob_Insert", connection)
                  command.CommandType = System.Data.CommandType.StoredProcedure
                  'parameters...
                  Dim jobNameParam As OleDb.OleDbParameter = command.Parameters.Add("@jobName", OleDb.OleDbType.VarChar, 50)
                  jobNameParam.Value = title.Text
                  Dim jobDescriptionParam As OleDb.OleDbParameter = command.Parameters.Add("@JobDescription", OleDb.OleDbType.VarChar, 50)
                  jobDescriptionParam.Value = description.Text
                  Dim statusIDParam As OleDb.OleDbParameter = command.Parameters.Add("@statusID", OleDb.OleDbType.Integer)
                  statusIDParam.Value = ddlStatus.SelectedItem.Value
                  'tbl_call parameters
                  Dim consultantIDParam As OleDb.OleDbParameter = command.Parameters.Add("@ConsultantID", OleDb.OleDbType.Integer)
                  consultantIDParam.Value = ddlperson.SelectedItem.Value
                  Dim callDateParam As OleDb.OleDbParameter = command.Parameters.Add("@calldate", OleDb.OleDbType.DBTimeStamp)
                  callDateParam.Value = nextCall.Text
                  Dim commentsParam As OleDb.OleDbParameter = command.Parameters.Add("@comments", System.Data.SqlDbType.VarChar, 50)
                  commentsParam.Value = "initiation call"

                  ' etc... add the remainder of your variables here
                  'execute...
                  command.ExecuteNonQuery()
                  'cleanup...
                  command.Dispose()
                  connection.Close()
            Catch ex As Exception
                  Return ex.Message
            End Try
      End Function
End Class
Avatar of lz7cjc

ASKER

crikey... thanks
I am using WebMatrix... will that make any difference?
i can that i need to create two pages here:
Yourformname.aspx.vb
YourPageName.aspx.vb

but i don't have a project to reference????

thanks
I've never used WebMatrix... does it support code-behind pages?
ASKER CERTIFIED SOLUTION
Avatar of Jeff Certain
Jeff Certain
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lz7cjc

ASKER

fantastic - you are amazing...
that works an absolute treat
thanks very much