Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Call Procedure in Visual Basic Expand / Collapse
Author
Message
Posted Monday, May 21, 2007 7:32 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, July 22, 2007 10:41 PM
Points: 2, Visits: 1

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

Post #367795
Posted Wednesday, May 23, 2007 4:43 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, October 22, 2007 1:18 AM
Points: 53, Visits: 4
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.
Post #368214
Posted Wednesday, May 23, 2007 10:35 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, July 22, 2007 10:41 PM
Points: 2, Visits: 1

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 

Post #368339
Posted Wednesday, May 23, 2007 10:39 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, October 22, 2007 1:18 AM
Points: 53, Visits: 4
Thanks. Happy SQL-ing =)







FP





True Love is Like A Ghost. Everyone Talks About It & Nobody have seen it.
Post #368341
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse