Question DELETE Code And Control Transfer Thru Enter Key

Ashfaque

Member
Joined
Nov 25, 2009
Messages
10
Programming Experience
Beginner
:)Hi,

I am quite new to DOT NET environment.

I use develop MS Access dbs for small shops and establishments. I could say I got success in vba codings in a smooth way.

I recently turned towards DOT NET environment. My net framework ver is 3.5and I installled sql server 2005 & Studio 2008 on my laptop.

I started developing a small db for a shop that contains 2-3 forms. I wrote codelines to add & modify record successfully.

I have 2 questions here.

1.

I am trying to write code to DELETE record after calling on form thru a combo with below simple code but produces error.

Private Sub CmdDelSupp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdDelSupp.Click

conn.Execute("Delete * from T_ProductMaster where ProdCode = '" & Val(TxtProdCode.Text) & "' and ProdName='" & Val(TxtProdName.Text) & "'")

End Sub

The error display at conn line is: COMexception was unhandled

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '*'.

Whats wrong here.

2.

I want to transfer control from one text box to another (next in tab order) thru by pressing ENTER key and not by Tab key which is bydefault

I know in VB I use to write KEYCODE=13 then..... but dot net is diff than what I learned in VBA of Access and Visual Basic.

Please extend your help.

With kind regards,
Ashfaque
 
If I put your connection string, nothing happened at runtime. No form is opening and system completely gone into indefinate loops which I dont know.

I require then to stop debugging and when I am going to save it always says Save As,,,,

Isn't there any simple code just to delete the record what I called it on form thru combo box. Even in Vb and MS access the method is simpler than DOT NET....zny other simple code please....

Thanks
 
Do not use ADO in a .NET world...use ADO.NET - try this
VB.NET:
Imports System.Data.SqlClient

Module AWSConnection

Public conn As SqlConnection

Public Sub Connect()        
        conn = New SqlConnection("Provider=MSDASQL.1;Persist Security _
                  Info=true;User ID=sa;Password=1234567890;DSN=AWS"")
        conn.Open()
    End Sub

End Module
 
Now the error is

ArgumentException were not handled
'Keyword not supported:'Provider'

One more thing, why there are "" (quotes) after DSN (end of line). It was also producing error. I kept only single quotes.

Thanks...
 
Back
Top