Showing posts with label example. Show all posts
Showing posts with label example. Show all posts

Friday, March 30, 2012

newbie question insert photos in sql 2k

Hello,
I am interested on how to insert a .jpg file into sql server 2k. Does
anyone have an example of this? I would greatly appreciate it.
Jakejake wrote:
> Hello,
> I am interested on how to insert a .jpg file into sql server 2k.
> Does anyone have an example of this? I would greatly appreciate it.
There are many approaches, but you might want to see:
HOWTO: Access and Modify SQL Server BLOB Data by Using the ADO Stream Object
http://support.microsoft.com/defaul...b;en-us;Q258038
FileToBlob - Loading a file into a SQL Server's BLOB
http://www.devx.com/vb2themax/Tip/19669
sincerely,
--
Sebastian K. Zaklada
Skilled Software
http://www.skilledsoftware.com
This posting is provided "AS IS" with no warranties, and confers no rights.

Friday, March 23, 2012

Newbie question

I would like to know how to be able to insert into one table for example and
have that table linked to another table.
For example, I have a Wrrok Order system VIA the Web, what happens is
someone will create a work order, and the records are created. I would like
to be able to dynamically add notes to it so that whenever a note is added
to a certain work order, it is added into a second table with a record
called notes (I have primary Keys on both Tables called "wo_id")
Then we I retrieve the Work Order using the Primary Key I want it to display
all of the notes in the secondary table related to that Primary Key.
Any help would be great, thanks and let me know if I did not ask it
correctly!> For example, I have a Wrrok Order system VIA the Web, what happens is
> someone will create a work order, and the records are created. I would
like
> to be able to dynamically add notes to it so that whenever a note is added
> to a certain work order, it is added into a second table with a record
> called notes (I have primary Keys on both Tables called "wo_id")
Just execute an INSERT statement with the wo_id for the work order and the
note for the second column.
> Then we I retrieve the Work Order using the Primary Key I want it to
display
> all of the notes in the secondary table related to that Primary Key.
Either first select the relevant columns from the WorkOrder table and
another SELECT that select the relevant columns from the other table.
SELECT col1, col2...
FROM WorkOrder
WHERE wo_id = ...
SELECT col1, col3
FROM SecTable
WHERE wo_id = ...
Or, do a join:
SELECT wo.col1, wo.col2, sec.col1, sec.col2
FROM WorkOrder AS wo INNER JOIN SecTable AS sec ON sec.wo_id = wo.wo_id
WHERE wo_id = ...
--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"JC" <Josh@.Network-Medics.Com> wrote in message
news:uWTMO8JpDHA.2188@.TK2MSFTNGP11.phx.gbl...
> I would like to know how to be able to insert into one table for example
and
> have that table linked to another table.
> For example, I have a Wrrok Order system VIA the Web, what happens is
> someone will create a work order, and the records are created. I would
like
> to be able to dynamically add notes to it so that whenever a note is added
> to a certain work order, it is added into a second table with a record
> called notes (I have primary Keys on both Tables called "wo_id")
> Then we I retrieve the Work Order using the Primary Key I want it to
display
> all of the notes in the secondary table related to that Primary Key.
> Any help would be great, thanks and let me know if I did not ask it
> correctly!
>|||Thanks!
"Tibor Karaszi" <tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
wrote in message news:evoRiLKpDHA.372@.TK2MSFTNGP11.phx.gbl...
> > For example, I have a Wrrok Order system VIA the Web, what happens is
> > someone will create a work order, and the records are created. I would
> like
> > to be able to dynamically add notes to it so that whenever a note is
added
> > to a certain work order, it is added into a second table with a record
> > called notes (I have primary Keys on both Tables called "wo_id")
> Just execute an INSERT statement with the wo_id for the work order and the
> note for the second column.
>
> > Then we I retrieve the Work Order using the Primary Key I want it to
> display
> > all of the notes in the secondary table related to that Primary Key.
> Either first select the relevant columns from the WorkOrder table and
> another SELECT that select the relevant columns from the other table.
> SELECT col1, col2...
> FROM WorkOrder
> WHERE wo_id = ...
> SELECT col1, col3
> FROM SecTable
> WHERE wo_id = ...
> Or, do a join:
> SELECT wo.col1, wo.col2, sec.col1, sec.col2
> FROM WorkOrder AS wo INNER JOIN SecTable AS sec ON sec.wo_id = wo.wo_id
> WHERE wo_id = ...
> --
> Tibor Karaszi, SQL Server MVP
> Archive at:
>
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
>
> "JC" <Josh@.Network-Medics.Com> wrote in message
> news:uWTMO8JpDHA.2188@.TK2MSFTNGP11.phx.gbl...
> > I would like to know how to be able to insert into one table for example
> and
> > have that table linked to another table.
> >
> > For example, I have a Wrrok Order system VIA the Web, what happens is
> > someone will create a work order, and the records are created. I would
> like
> > to be able to dynamically add notes to it so that whenever a note is
added
> > to a certain work order, it is added into a second table with a record
> > called notes (I have primary Keys on both Tables called "wo_id")
> >
> > Then we I retrieve the Work Order using the Primary Key I want it to
> display
> > all of the notes in the secondary table related to that Primary Key.
> >
> > Any help would be great, thanks and let me know if I did not ask it
> > correctly!
> >
> >
>

Wednesday, March 21, 2012

Newbie Query Syntax question

I just need to restore a deleted table from a local backup of the entire
database. For my example the database name is MYDB and the table MYTABL. I
THINK I understand the start to be:
USE MYDB
Go
Restore Database MYDB
From MYDB
Disk = 'C:\Location of folder\MYDB.bak
With NORECOVERY
MOVE
and from there I am stumped. I am not sure about the FILE clause and
"Logical file name" v. "Operating system file name"
Thanks in advance for any help.
I'm sorry, Monty, but there's no single table restore facility in SQL Server (think about data integrity and
relationships between tables).
You can restore the whole database into a new database (use MOVE option to specify new physical file names)
and then copy the desired table(s)/data into your production database.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Monty" <montysl@.nospam.hotmail.com> wrote in message news:uKYJNBVgEHA.3932@.TK2MSFTNGP09.phx.gbl...
> I just need to restore a deleted table from a local backup of the entire
> database. For my example the database name is MYDB and the table MYTABL. I
> THINK I understand the start to be:
> USE MYDB
> Go
> Restore Database MYDB
> From MYDB
> Disk = 'C:\Location of folder\MYDB.bak
> With NORECOVERY
> MOVE
> and from there I am stumped. I am not sure about the FILE clause and
> "Logical file name" v. "Operating system file name"
> Thanks in advance for any help.
>
>
|||Thanks Tibor...I had been looking for the answer all morning...Thought I was
missing something.....feel slightly less ignorant of the matter now.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23tNy3CVgEHA.704@.TK2MSFTNGP09.phx.gbl...
> I'm sorry, Monty, but there's no single table restore facility in SQL
Server (think about data integrity and
> relationships between tables).
> You can restore the whole database into a new database (use MOVE option to
specify new physical file names)
> and then copy the desired table(s)/data into your production database.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Monty" <montysl@.nospam.hotmail.com> wrote in message
news:uKYJNBVgEHA.3932@.TK2MSFTNGP09.phx.gbl...[vbcol=seagreen]
I
>
sql

Newbie Query Syntax question

I just need to restore a deleted table from a local backup of the entire
database. For my example the database name is MYDB and the table MYTABL. I
THINK I understand the start to be:
USE MYDB
Go
Restore Database MYDB
From MYDB
Disk = 'C:\Location of folder\MYDB.bak
With NORECOVERY
MOVE
and from there I am stumped. I am not sure about the FILE clause and
"Logical file name" v. "Operating system file name"
Thanks in advance for any help.I'm sorry, Monty, but there's no single table restore facility in SQL Server
(think about data integrity and
relationships between tables).
You can restore the whole database into a new database (use MOVE option to s
pecify new physical file names)
and then copy the desired table(s)/data into your production database.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Monty" <montysl@.nospam.hotmail.com> wrote in message news:uKYJNBVgEHA.3932@.TK2MSFTNGP09.phx
.gbl...
> I just need to restore a deleted table from a local backup of the entire
> database. For my example the database name is MYDB and the table MYTABL. I
> THINK I understand the start to be:
> USE MYDB
> Go
> Restore Database MYDB
> From MYDB
> Disk = 'C:\Location of folder\MYDB.bak
> With NORECOVERY
> MOVE
> and from there I am stumped. I am not sure about the FILE clause and
> "Logical file name" v. "Operating system file name"
> Thanks in advance for any help.
>
>|||Thanks Tibor...I had been looking for the answer all morning...Thought I was
missing something.....feel slightly less ignorant of the matter now.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23tNy3CVgEHA.704@.TK2MSFTNGP09.phx.gbl...
> I'm sorry, Monty, but there's no single table restore facility in SQL
Server (think about data integrity and
> relationships between tables).
> You can restore the whole database into a new database (use MOVE option to
specify new physical file names)
> and then copy the desired table(s)/data into your production database.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Monty" <montysl@.nospam.hotmail.com> wrote in message
news:uKYJNBVgEHA.3932@.TK2MSFTNGP09.phx.gbl...
I[vbcol=seagreen]
>

Newbie Query Syntax question

I just need to restore a deleted table from a local backup of the entire
database. For my example the database name is MYDB and the table MYTABL. I
THINK I understand the start to be:
USE MYDB
Go
Restore Database MYDB
From MYDB
Disk = 'C:\Location of folder\MYDB.bak
With NORECOVERY
MOVE
and from there I am stumped. I am not sure about the FILE clause and
"Logical file name" v. "Operating system file name"
Thanks in advance for any help.I'm sorry, Monty, but there's no single table restore facility in SQL Server (think about data integrity and
relationships between tables).
You can restore the whole database into a new database (use MOVE option to specify new physical file names)
and then copy the desired table(s)/data into your production database.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Monty" <montysl@.nospam.hotmail.com> wrote in message news:uKYJNBVgEHA.3932@.TK2MSFTNGP09.phx.gbl...
> I just need to restore a deleted table from a local backup of the entire
> database. For my example the database name is MYDB and the table MYTABL. I
> THINK I understand the start to be:
> USE MYDB
> Go
> Restore Database MYDB
> From MYDB
> Disk = 'C:\Location of folder\MYDB.bak
> With NORECOVERY
> MOVE
> and from there I am stumped. I am not sure about the FILE clause and
> "Logical file name" v. "Operating system file name"
> Thanks in advance for any help.
>
>|||Thanks Tibor...I had been looking for the answer all morning...Thought I was
missing something.....feel slightly less ignorant of the matter now.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23tNy3CVgEHA.704@.TK2MSFTNGP09.phx.gbl...
> I'm sorry, Monty, but there's no single table restore facility in SQL
Server (think about data integrity and
> relationships between tables).
> You can restore the whole database into a new database (use MOVE option to
specify new physical file names)
> and then copy the desired table(s)/data into your production database.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Monty" <montysl@.nospam.hotmail.com> wrote in message
news:uKYJNBVgEHA.3932@.TK2MSFTNGP09.phx.gbl...
> > I just need to restore a deleted table from a local backup of the entire
> > database. For my example the database name is MYDB and the table MYTABL.
I
> > THINK I understand the start to be:
> >
> > USE MYDB
> > Go
> > Restore Database MYDB
> > From MYDB
> > Disk = 'C:\Location of folder\MYDB.bak
> > With NORECOVERY
> > MOVE
> >
> > and from there I am stumped. I am not sure about the FILE clause and
> > "Logical file name" v. "Operating system file name"
> >
> > Thanks in advance for any help.
> >
> >
> >
>

Monday, March 19, 2012

Newbie needs help

Hi,
I am using SQLEXPRESS running locally on my machine and am trying to create
a database (AdventureWorks) for an example that I am using. What complicates
this a bit is that this example is using NAnt. The local.properties.xml file
contains the following:
<?xml version="1.0"?>
<properties>
<property name="sqlToolsFolder" value="C:\Program Files\Microsoft SQL
Server\90\Tools\Binn"/>
<property name="osql.ConnectionString" value="-E"/>
<property name="initial.catalog" value="AdventureWorks"/>
<property name="config.ConnectionString" value="data
source=SQLEXPRESS;Integrated Security=SSPI;Initial
Catalog=${initial.catalog}"/> <property name="database.path"
value="C:\root\development\databases" />
<property name="osql.exe" value="${sqlToolsFolder}\osql.exe" />
</properties>
When I open the Enterprise Manager and run the script for attach.sql the
database is created fine.
when I run the "build builddb" I get the following error:
NAnt 0.85 (Build 0.85.2139.0; nightly; 11/9/2005)
Copyright (C) 2001-2005 Gerry Shaw
http://nant.sourceforge.net
Buildfile: file:///C:/root/development/playground/adventureworks/avworks.bui
ld
Target framework: Microsoft .NET Framework 2.0
Target(s) specified: builddb
[echo] Loading local.properties.xml
builddb:
exec.sql.template:
convert.template:
[copy] Copying 1 file to
'C:\root\development\playground\adventur
eworks\sql
\attach.sql'.
[exec] Msg 1813, Level 16, State 2, Server OHBOCXX99RMRVK, Line 1
[exec] Could not open new database 'AdventureWorks'. CREATE DATABASE is
aborted.
[exec] Msg 602, Level 21, State 50, Server OHBOCXX99RMRVK, Line 1
[exec] Could not find row in sysindexes for database ID 13, object ID
1, in
dex ID 1.
[exec] Run DBCC CHECKTABLE on sysindexes.
BUILD FAILED
C:\root\development\playground\adventure
works\avworks.build(60,10):
External Program Failed: C:\Program Files\Microsoft SQL
Server\90\Tools\Binn\osq
l.exe (return code was 1)
Total time: 1.8 seconds.
When I installed SQLEXPRESS, I installed it using Windows Authentication and
I would think that Integrated Security would work. I'll bet I'm doing
something silly, but I've tried to figure it out with no luck.
thanks in advance!
BillChances are they are using the AdventureWorks sample database which come
populated with a bunch of sample data. You can download it here:
http://www.microsoft.com/downloads/...&displaylang=en
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Bill44077" <Bill44077@.discussions.microsoft.com> wrote in message
news:A1B3826A-0D0F-4B1F-804A-DB222842D778@.microsoft.com...
> Hi,
> I am using SQLEXPRESS running locally on my machine and am trying to
> create
> a database (AdventureWorks) for an example that I am using. What
> complicates
> this a bit is that this example is using NAnt. The local.properties.xml
> file
> contains the following:
> <?xml version="1.0"?>
> <properties>
> <property name="sqlToolsFolder" value="C:\Program Files\Microsoft SQL
> Server\90\Tools\Binn"/>
> <property name="osql.ConnectionString" value="-E"/>
> <property name="initial.catalog" value="AdventureWorks"/>
> <property name="config.ConnectionString" value="data
> source=SQLEXPRESS;Integrated Security=SSPI;Initial
> Catalog=${initial.catalog}"/> <property name="database.path"
> value="C:\root\development\databases" />
> <property name="osql.exe" value="${sqlToolsFolder}\osql.exe" />
> </properties>
> When I open the Enterprise Manager and run the script for attach.sql the
> database is created fine.
> when I run the "build builddb" I get the following error:
> NAnt 0.85 (Build 0.85.2139.0; nightly; 11/9/2005)
> Copyright (C) 2001-2005 Gerry Shaw
> http://nant.sourceforge.net
> Buildfile:
> file:///C:/root/development/playground/adventureworks/avworks.build
> Target framework: Microsoft .NET Framework 2.0
> Target(s) specified: builddb
> [echo] Loading local.properties.xml
> builddb:
>
> exec.sql.template:
>
> convert.template:
> [copy] Copying 1 file to
> 'C:\root\development\playground\adventur
eworks\sql
> \attach.sql'.
> [exec] Msg 1813, Level 16, State 2, Server OHBOCXX99RMRVK, Line 1
> [exec] Could not open new database 'AdventureWorks'. CREATE DATABA
SE
> is
> aborted.
> [exec] Msg 602, Level 21, State 50, Server OHBOCXX99RMRVK, Line 1
> [exec] Could not find row in sysindexes for database ID 13, object
ID
> 1, in
> dex ID 1.
> [exec] Run DBCC CHECKTABLE on sysindexes.
> BUILD FAILED
> C:\root\development\playground\adventure
works\avworks.build(60,10):
> External Program Failed: C:\Program Files\Microsoft SQL
> Server\90\Tools\Binn\osq
> l.exe (return code was 1)
> Total time: 1.8 seconds.
> When I installed SQLEXPRESS, I installed it using Windows Authentication
> and
> I would think that Integrated Security would work. I'll bet I'm doing
> something silly, but I've tried to figure it out with no luck.
> thanks in advance!
> Bill

Saturday, February 25, 2012

Newbie - SqlConnection statement

I'm trying to get a combobox to fill with values from a table. I've
set up an example using the Northwind database with the Categories
table. Dragging in the CategoryID field onto my form as a combobox,
I've set the following properties for the CategoryID combobox:
Value member = "CategoriesBindingSource - CategoryID"
Display Member = "CategoriesBindingSource - CategoryID"
This seems to bring in the correct values in the two non-index fields
(CategoryName and Description). I've then added the following code to
the combobox:
Dim Conn As SqlConnection
Conn = New SqlConnection("Database=Northwnd.mdf")
'Conn.Open()
Dim da As SqlDataAdapter = New SqlDataAdapter("SELECT
CategoryID FROM Categories", Conn)
Dim ds As New DataSet
da.Fill(ds, "Categories")
CategoryIDComboBox.DataSource = ds
'CategoryIDComboBox.ValueMember = "CategoryID"
'CategoryIDComboBox.DisplayMember = "CategoryID"
End Sub
The lines that are commented out are other ideas that I've tried to no
avail. I left them here in case they are relevant.
I suspect that at least part of my problem is in the SqlDataAdapter
statement where I am pointing to the database. I am working on a
standalone pc.
Can anybody see where I am going wrong?
Thanks,
RandyHi Randy
"Randy" wrote:

> I'm trying to get a combobox to fill with values from a table. I've
> set up an example using the Northwind database with the Categories
> table. Dragging in the CategoryID field onto my form as a combobox,
> I've set the following properties for the CategoryID combobox:
> Value member = "CategoriesBindingSource - CategoryID"
> Display Member = "CategoriesBindingSource - CategoryID"
> This seems to bring in the correct values in the two non-index fields
> (CategoryName and Description). I've then added the following code to
> the combobox:
> Dim Conn As SqlConnection
> Conn = New SqlConnection("Database=Northwnd.mdf")
> 'Conn.Open()
> Dim da As SqlDataAdapter = New SqlDataAdapter("SELECT
> CategoryID FROM Categories", Conn)
> Dim ds As New DataSet
> da.Fill(ds, "Categories")
> CategoryIDComboBox.DataSource = ds
> 'CategoryIDComboBox.ValueMember = "CategoryID"
> 'CategoryIDComboBox.DisplayMember = "CategoryID"
> End Sub
> The lines that are commented out are other ideas that I've tried to no
> avail. I left them here in case they are relevant.
> I suspect that at least part of my problem is in the SqlDataAdapter
> statement where I am pointing to the database. I am working on a
> standalone pc.
> Can anybody see where I am going wrong?
> Thanks,
> Randy
>
For connection string information check out
http://www.connectionstrings.com/?carrier=sqlserver2005
You may also want to some of the examples such as
http://msdn.microsoft.com/library/d...opi
c.asp
John

Newbie - SqlConnection statement

I'm trying to get a combobox to fill with values from a table. I've
set up an example using the Northwind database with the Categories
table. Dragging in the CategoryID field onto my form as a combobox,
I've set the following properties for the CategoryID combobox:
Value member = "CategoriesBindingSource - CategoryID"
Display Member = "CategoriesBindingSource - CategoryID"
This seems to bring in the correct values in the two non-index fields
(CategoryName and Description). I've then added the following code to
the combobox:
Dim Conn As SqlConnection
Conn = New SqlConnection("Database=Northwnd.mdf")
'Conn.Open()
Dim da As SqlDataAdapter = New SqlDataAdapter("SELECT
CategoryID FROM Categories", Conn)
Dim ds As New DataSet
da.Fill(ds, "Categories")
CategoryIDComboBox.DataSource = ds
'CategoryIDComboBox.ValueMember = "CategoryID"
'CategoryIDComboBox.DisplayMember = "CategoryID"
End Sub
The lines that are commented out are other ideas that I've tried to no
avail. I left them here in case they are relevant.
I suspect that at least part of my problem is in the SqlDataAdapter
statement where I am pointing to the database. I am working on a
standalone pc.
Can anybody see where I am going wrong?
Thanks,
Randy
Hi Randy
"Randy" wrote:

> I'm trying to get a combobox to fill with values from a table. I've
> set up an example using the Northwind database with the Categories
> table. Dragging in the CategoryID field onto my form as a combobox,
> I've set the following properties for the CategoryID combobox:
> Value member = "CategoriesBindingSource - CategoryID"
> Display Member = "CategoriesBindingSource - CategoryID"
> This seems to bring in the correct values in the two non-index fields
> (CategoryName and Description). I've then added the following code to
> the combobox:
> Dim Conn As SqlConnection
> Conn = New SqlConnection("Database=Northwnd.mdf")
> 'Conn.Open()
> Dim da As SqlDataAdapter = New SqlDataAdapter("SELECT
> CategoryID FROM Categories", Conn)
> Dim ds As New DataSet
> da.Fill(ds, "Categories")
> CategoryIDComboBox.DataSource = ds
> 'CategoryIDComboBox.ValueMember = "CategoryID"
> 'CategoryIDComboBox.DisplayMember = "CategoryID"
> End Sub
> The lines that are commented out are other ideas that I've tried to no
> avail. I left them here in case they are relevant.
> I suspect that at least part of my problem is in the SqlDataAdapter
> statement where I am pointing to the database. I am working on a
> standalone pc.
> Can anybody see where I am going wrong?
> Thanks,
> Randy
>
For connection string information check out
http://www.connectionstrings.com/?carrier=sqlserver2005
You may also want to some of the examples such as
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqlclientsqlconnectionclasstopic.as p[/url]
John

Newbie - SqlConnection statement

I'm trying to get a combobox to fill with values from a table. I've
set up an example using the Northwind database with the Categories
table. Dragging in the CategoryID field onto my form as a combobox,
I've set the following properties for the CategoryID combobox:
Value member = "CategoriesBindingSource - CategoryID"
Display Member = "CategoriesBindingSource - CategoryID"
This seems to bring in the correct values in the two non-index fields
(CategoryName and Description). I've then added the following code to
the combobox:
Dim Conn As SqlConnection
Conn = New SqlConnection("Database=Northwnd.mdf")
'Conn.Open()
Dim da As SqlDataAdapter = New SqlDataAdapter("SELECT
CategoryID FROM Categories", Conn)
Dim ds As New DataSet
da.Fill(ds, "Categories")
CategoryIDComboBox.DataSource = ds
'CategoryIDComboBox.ValueMember = "CategoryID"
'CategoryIDComboBox.DisplayMember = "CategoryID"
End Sub
The lines that are commented out are other ideas that I've tried to no
avail. I left them here in case they are relevant.
I suspect that at least part of my problem is in the SqlDataAdapter
statement where I am pointing to the database. I am working on a
standalone pc.
Can anybody see where I am going wrong?
Thanks,
RandyHi Randy
"Randy" wrote:
> I'm trying to get a combobox to fill with values from a table. I've
> set up an example using the Northwind database with the Categories
> table. Dragging in the CategoryID field onto my form as a combobox,
> I've set the following properties for the CategoryID combobox:
> Value member = "CategoriesBindingSource - CategoryID"
> Display Member = "CategoriesBindingSource - CategoryID"
> This seems to bring in the correct values in the two non-index fields
> (CategoryName and Description). I've then added the following code to
> the combobox:
> Dim Conn As SqlConnection
> Conn = New SqlConnection("Database=Northwnd.mdf")
> 'Conn.Open()
> Dim da As SqlDataAdapter = New SqlDataAdapter("SELECT
> CategoryID FROM Categories", Conn)
> Dim ds As New DataSet
> da.Fill(ds, "Categories")
> CategoryIDComboBox.DataSource = ds
> 'CategoryIDComboBox.ValueMember = "CategoryID"
> 'CategoryIDComboBox.DisplayMember = "CategoryID"
> End Sub
> The lines that are commented out are other ideas that I've tried to no
> avail. I left them here in case they are relevant.
> I suspect that at least part of my problem is in the SqlDataAdapter
> statement where I am pointing to the database. I am working on a
> standalone pc.
> Can anybody see where I am going wrong?
> Thanks,
> Randy
>
For connection string information check out
http://www.connectionstrings.com/?carrier=sqlserver2005
You may also want to some of the examples such as
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqlclientsqlconnectionclasstopic.asp
John