Soren Forsdahl
3/27/2002 10:37:00 AM
Hey.
I just started to learn about odbc with vb .net.
I use also Sybase SQL Anywhere 6 i my work.
But we use clarion to code in, but we shall move to
vb .net.
But we have to use Sybase SQL Anywhere 6 databas.
Have you any sample that i can get to se who it wold be??
Greetz Soren Forsdahl
Analys Consult KB
Sweden
>-----Original Message-----
>David,
>
>some more food for thoughts:
>
>1) This is the initial code:
>
>odbcConnection = new System.Data.Odbc.OdbcConnection();
> odbcConnection.ConnectionString >"DSN=myDSN;UIDÛa;PWD=sql;DatabaseFile=C:\\\\TheProject\\
\\TheDatabase.db;"
>+ "AutoStop=YES;Integrated=NO;Debug=NO;DisableMultiRowFetc
h=NO";
> odbcConnection.Open();
>OdbcTransaction trans;
>trans = odbcConnection.BeginTransaction();
>
>try {
>
> // Use params here
> String updSql = "UPDATE A_TAB set
a_char_field_id = ? where
>an_autoincremen_field = ?";
> OdbcCommand updCmd = new OdbcCommand(updSql,
odbcConnection);
> updCmd.Transaction = trans;
> updCmd.Parameters.Add("@char_fld",
OdbcType.VarChar, 30).Value >MyId.Text;
> updCmd.Parameters.Add("@auto_inc",
OdbcType.Int).Value = id;
> updCmd.ExecuteNonQuery();
> trans.Commit();
> } catch(Exception e1) {
> trans.Rollback();
> Response.Write(e1.ToString());
> } finally {
> odbcConnection.Close();
> }
> }
>
>MyId is described as <asp:TextBox id="MyId" width="100%"
runat="server"/>
>
>This code does not work.
>
>2) Now, lets replace the line:
> updCmd.Parameters.Add("@char_fld",
OdbcType.VarChar, 30).Value >MyId.Text;
>with
> String s = MyId.Text;
> updCmd.Parameters.Add("@char_fld",
OdbcType.VarChar, 30).Value >s;
>
>Does not work either
>
>3) Lets replace the line:
> updCmd.Parameters.Add("@char_fld",
OdbcType.VarChar, 30).Value >MyId.Text;
>with
> String s = "MyStaticString";
> updCmd.Parameters.Add("@char_fld",
OdbcType.VarChar, 30).Value >s;
>
>This code works.
>Did I miss something?
>
>Thanks,
>Alexander Glazkov (GL)
>
>
>
>.
>