Call Procedure in Visual Basic

  • Hi everybody,

     

    i swear someone can help me here

    i'm trying to call stored procedure......here is my code

    ' Connect to the data source using the Open

    ' method of an ADODB.Connection object..

    Dim con As New ADODB.Connection

    con.Open(

    "provider = .NET Framework Data Provider for SQL Server")

    con.string =

    "productid.mdf;Initial Catalog=Product;Integrated Security=True;Pooling=False;uid=uid;pwd=pwd "

    ' Create an ADODB.Command object that uses the

    ' connection object "con", and calls the stored

    ' procedure named "proc1"..

    Dim cmd As New ADODB.Command

    cmd.ActiveConnection = con

    cmd.CommandType = CommandType.StoredProcedure

    cmd.CommandText =

    "insertcustomer"

    ' Call the stored procedure..

    cmd.Execute()

    ' Disconnect from the data source..

    con.Close()

    End Sub

    and i have an error when i run it they error is

    "Provider cannot be found. It may not be properly installed."

    anyone here have isssue how to resolve this bug

    Thanks you

  • The correct driver name is "Provider = SQLNCLI" for dot net native driver for sql server.

    Instead of using connection string, put directly in the open() method.

    con.Open("Provider = SQLNCLI;Data Source = myserver; Database=mydb;", "user", "password")

    Please use this and let me know if you have a problem ... Thanks.

    FP


    FP

    True Love is Like A Ghost. Everyone Talks About It & Nobody have seen it.

  • thanks grooshopper but i resolve my probleme here my code is now

    Dim

    sqlcon As New SqlClient.SqlConnection

    sqlcon.ConnectionString =

    "Data Source=WISEMAN\SQLEXPRESS;Initial Catalog=Productdetail;Integrated Security=True;Pooling=False;uid=uid;pwd=pwd "

    Dim cmd As New SqlClient.SqlCommand

    cmd.Connection = sqlcon

    cmd.CommandType = CommandType.StoredProcedure

    cmd.CommandText =

    "insertcustomer"

    cmd.Parameters.AddWithValue(

    "@detail", TextBox2.Text)

    sqlcon.Open()

    cmd.ExecuteScalar()

    sqlcon.Close()

     

    and now it work fine for my delete,update,and insert Procedure

     

    thanks you for the help 

  • Thanks. Happy SQL-ing =)


    FP

    True Love is Like A Ghost. Everyone Talks About It & Nobody have seen it.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply