MSDE 2000 and ado.net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using the MSDE 2000 and ado.net. When I use the sqldataadapter wizard it
won't generate some statements unless the primary key is designated. I tried
using char, nchar, int, sql variant, and nvarchar.When I use these data types
they allow a primary key and so the sqlwizard generates all the statements.
But, somehow the string that I am trying to put into the msde is truncated
and only a part of the string is held in the dataset.

I can use ntext or text and the entire string is held in the database, but
these data types won't allow you to generate a primary key so the sqlwizard
doesn't generate all the required statements and I believe the ado wasn't
working correctly so I couldn't update the database correctly. I have looked
over the MSDE documentation and am wondering if I can use the sql wizard at
all and if I have to perhaps do everything manually. This seems kind of far
out because MSDE is popular. Thanks for your help.

Spencer
 
Ah, and make sure you give enough space to your string, i.e. varchar(1000)
will take only 1000 chars at maximum.
 
I tried varchar(600), was able to set a primary key , but the string was
still truncated. Here's my code:

Dataset ds = new Dataset() //This is not the same dataset
generated by
//by generate-dataset

sqldataadapter1.fill(ds) //I am using the sqladapter
generated by the
//wizard
DataTable dt1 = new DataTable()
dt1 = ds.Tables[0]
DataRow dr1 = dt1.NewRow()
dr1[0] = ListBox1.Items[0].ToString()
dt1.Rows.Add(dr1)
sqldataadapter1.Update(ds)

Note: dr1[0] contains the entire string I want to put in the database. After
the add ds.tables[0].rows[0].itemarray[0].tostring() contains only the
truncated string. If I use ntext this works, but as I mentioned the wizard
doesn't like it because of the PK. Thanks for all your help.

Spencer


Miha Markic said:
Ah, and make sure you give enough space to your string, i.e. varchar(1000)
will take only 1000 chars at maximum.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
SLODUG - Slovene Developer Users Group www.codezone-si.info

Spencer H. Prue said:
I am using the MSDE 2000 and ado.net. When I use the sqldataadapter wizard
it
won't generate some statements unless the primary key is designated. I
tried
using char, nchar, int, sql variant, and nvarchar.When I use these data
types
they allow a primary key and so the sqlwizard generates all the
statements.
But, somehow the string that I am trying to put into the msde is truncated
and only a part of the string is held in the dataset.

I can use ntext or text and the entire string is held in the database, but
these data types won't allow you to generate a primary key so the
sqlwizard
doesn't generate all the required statements and I believe the ado wasn't
working correctly so I couldn't update the database correctly. I have
looked
over the MSDE documentation and am wondering if I can use the sql wizard
at
all and if I have to perhaps do everything manually. This seems kind of
far
out because MSDE is popular. Thanks for your help.

Spencer
 
Spencer,

Check out ds.Tables[0].Columns[0].MaxLength property to see what's going on.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
SLODUG - Slovene Developer Users Group www.codezone-si.info

Spencer H. Prue said:
I tried varchar(600), was able to set a primary key , but the string was
still truncated. Here's my code:

Dataset ds = new Dataset() //This is not the same dataset
generated by
//by generate-dataset

sqldataadapter1.fill(ds) //I am using the sqladapter
generated by the
//wizard
DataTable dt1 = new DataTable()
dt1 = ds.Tables[0]
DataRow dr1 = dt1.NewRow()
dr1[0] = ListBox1.Items[0].ToString()
dt1.Rows.Add(dr1)
sqldataadapter1.Update(ds)

Note: dr1[0] contains the entire string I want to put in the database.
After
the add ds.tables[0].rows[0].itemarray[0].tostring() contains only the
truncated string. If I use ntext this works, but as I mentioned the wizard
doesn't like it because of the PK. Thanks for all your help.

Spencer


Miha Markic said:
Ah, and make sure you give enough space to your string, i.e.
varchar(1000)
will take only 1000 chars at maximum.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
SLODUG - Slovene Developer Users Group www.codezone-si.info

message
I am using the MSDE 2000 and ado.net. When I use the sqldataadapter
wizard
it
won't generate some statements unless the primary key is designated. I
tried
using char, nchar, int, sql variant, and nvarchar.When I use these data
types
they allow a primary key and so the sqlwizard generates all the
statements.
But, somehow the string that I am trying to put into the msde is
truncated
and only a part of the string is held in the dataset.

I can use ntext or text and the entire string is held in the database,
but
these data types won't allow you to generate a primary key so the
sqlwizard
doesn't generate all the required statements and I believe the ado
wasn't
working correctly so I couldn't update the database correctly. I have
looked
over the MSDE documentation and am wondering if I can use the sql
wizard
at
all and if I have to perhaps do everything manually. This seems kind of
far
out because MSDE is popular. Thanks for your help.

Spencer
 
Hello again,

I tried ds.tables[0].columns[0].maxlength and got a -1 back. Thanks for your
help.

Spence

Miha Markic said:
Spencer,

Check out ds.Tables[0].Columns[0].MaxLength property to see what's going on.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
SLODUG - Slovene Developer Users Group www.codezone-si.info

Spencer H. Prue said:
I tried varchar(600), was able to set a primary key , but the string was
still truncated. Here's my code:

Dataset ds = new Dataset() //This is not the same dataset
generated by
//by generate-dataset

sqldataadapter1.fill(ds) //I am using the sqladapter
generated by the
//wizard
DataTable dt1 = new DataTable()
dt1 = ds.Tables[0]
DataRow dr1 = dt1.NewRow()
dr1[0] = ListBox1.Items[0].ToString()
dt1.Rows.Add(dr1)
sqldataadapter1.Update(ds)

Note: dr1[0] contains the entire string I want to put in the database.
After
the add ds.tables[0].rows[0].itemarray[0].tostring() contains only the
truncated string. If I use ntext this works, but as I mentioned the wizard
doesn't like it because of the PK. Thanks for all your help.

Spencer


Miha Markic said:
Ah, and make sure you give enough space to your string, i.e.
varchar(1000)
will take only 1000 chars at maximum.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
SLODUG - Slovene Developer Users Group www.codezone-si.info

message
I am using the MSDE 2000 and ado.net. When I use the sqldataadapter
wizard
it
won't generate some statements unless the primary key is designated. I
tried
using char, nchar, int, sql variant, and nvarchar.When I use these data
types
they allow a primary key and so the sqlwizard generates all the
statements.
But, somehow the string that I am trying to put into the msde is
truncated
and only a part of the string is held in the dataset.

I can use ntext or text and the entire string is held in the database,
but
these data types won't allow you to generate a primary key so the
sqlwizard
doesn't generate all the required statements and I believe the ado
wasn't
working correctly so I couldn't update the database correctly. I have
looked
over the MSDE documentation and am wondering if I can use the sql
wizard
at
all and if I have to perhaps do everything manually. This seems kind of
far
out because MSDE is popular. Thanks for your help.

Spencer
 
Back
Top