Article View: free.it.visual-basic
Article #2316ADODB Help me
From: Michelangelo
Date: Mon, 14 Jul 2003 15:56
Date: Mon, 14 Jul 2003 15:56
162 lines
7556 bytes
7556 bytes
This is a multi-part message in MIME format.
------=_NextPart_000_001E_01C34A31.357E04D0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Salve a tutti,
ho un piccolo problema nel recuperare la struttura di una tabella in =
specifico mi interessa recuperare se un campo =E8 null o meno su SQL =
SERVER e non su Access. Questo =E8 il mio codice ma non so cosa non =
funziona. Dopo aver impostato la connessione appena arriva alla riga per =
dirmi se il campo =E8 un campo dove viene accettato anche il valore =
NULL, si blocca!
Centra il modo di apertura del database?
Code:
Private function Required()
Dim StrConnection As String
Dim Cn As ADODB.Connection
Dim Tbl As New ADOX.Table
Dim Col As ADOX.Column
UserID =3D "sa"
Password =3D "11041977"
DatabaseName =3D "data"
ServerName =3D "ShineServer"
Set Cn =3D New ADODB.Connection
With Cn
If Cn.State =3D adStateOpen Then
Cn.Close
End If
=20
Select Case connectiontype
Case "Microsoft Access 2000"
StrConnection =3D =
"Provider=3DMicrosoft.Jet.OLEDB.4.0;Data Source=3D" & ConnectString & =
";Persist Security Info=3DFalse"
Case "Microsoft SQL Server 2003"
StrConnection =3D "Provider=3DSQLOLEDB.1;Persist =
Security Info=3DFalse;User ID=3D" & UserID & ";Password=3D" & Password & =
";Initial Catalog=3D" & DatabaseName & ";Data Source=3D" & ServerName
End Select
.ConnectionString =3D StrConnection
.Open
DatabaseType =3D connectiontype
fnConnectionString =3D True
Set Conn =3D Cn
End With
=20
=20
Set Tbl =3D Cn.Tables(StrTable)
Set Col =3D Tbl.Columns(strField)
RequiredField =3D Col.Properties("Nullable").Value ---> ERRORE:=20
End function
------=_NextPart_000_001E_01C34A31.357E04D0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Salve a tutti,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> ho un piccolo =
problema nel=20
recuperare la struttura di una tabella in specifico mi interessa =
recuperare se=20
un campo =E8 null o meno su SQL SERVER e non su Access. Questo =E8 il =
mio codice ma=20
non so cosa non funziona. Dopo aver impostato la connessione appena =
arriva alla=20
riga per dirmi se il campo =E8 un campo dove viene accettato anche il =
valore NULL,=20
si blocca!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Centra il modo di apertura del=20
database?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV>
<DIV><SPAN class=3D218580813-14072003><FONT face=3DArial=20
size=3D2><STRONG>Code:</STRONG></FONT></SPAN></DIV>
<DIV><SPAN class=3D218580813-14072003><STRONG><FONT face=3DArial=20
size=3D2></FONT></STRONG></SPAN> </DIV>
<DIV><FONT face=3DTahoma color=3D#0000ff size=3D2>Private function =
Required()<BR><FONT=20
color=3D#000000> Dim StrConnection As=20
String<BR> Dim Cn As =
ADODB.Connection<BR> =20
Dim Tbl As New ADOX.Table<BR> Dim Col As=20
ADOX.Column<BR></FONT></FONT><FONT face=3DTahoma size=3D2></FONT></DIV>
<DIV><FONT face=3DTahoma size=3D2> UserID =3D=20
"sa"</FONT></DIV></DIV>
<DIV>
<DIV><FONT face=3DTahoma size=3D2> Password =3D=20
"11041977"</FONT></DIV>
<DIV><FONT face=3DTahoma size=3D2> DatabaseName =3D=20
"data"</FONT></DIV>
<DIV><FONT face=3DTahoma size=3D2> ServerName =3D=20
"ShineServer"</FONT></DIV>
<DIV><BR><FONT face=3DTahoma size=3D2> Set Cn =3D New=20
ADODB.Connection<BR> With=20
Cn<BR> If Cn.State =3D adStateOpen=20
Then<BR> =20
Cn.Close<BR> End=20
If<BR> =20
<BR> Select Case=20
connectiontype<BR> &=
nbsp; =20
Case "Microsoft Access=20
2000"<BR> &nbs=
p; =20
StrConnection =3D "Provider=3DMicrosoft.Jet.OLEDB.4.0;Data Source=3D" =
&=20
ConnectString & ";Persist Security=20
Info=3DFalse"<BR> &n=
bsp; =20
Case "Microsoft SQL Server=20
2003"<BR> &nbs=
p; =20
StrConnection =3D "<STRONG>Provider=3DSQLOLEDB.1</STRONG>;Persist =
Security=20
Info=3DFalse;User ID=3D" & UserID & ";Password=3D" & =
Password &=20
";Initial Catalog=3D" & DatabaseName & ";Data Source=3D" =
&=20
ServerName<BR> End=20
Select<BR> .ConnectionString =3D=20
StrConnection<BR> =20
.Open<BR> DatabaseType =3D=20
connectiontype<BR> =
fnConnectionString =3D=20
True<BR> Set Conn =3D =
Cn<BR> =20
End With<BR> <BR> =
<BR> Set=20
Tbl =3D Cn.Tables(StrTable)<BR> Set Col =3D=20
Tbl.Columns(strField)</FONT></DIV>
<DIV><FONT face=3DTahoma size=3D2></FONT> </DIV>
<DIV><FONT face=3DTahoma size=3D2> <STRONG> =
RequiredField =3D=20
Col.Properties("Nullable").Value ---> ERRORE: =
</STRONG></FONT></DIV>
<DIV><FONT face=3DTahoma color=3D#0000ff size=3D2></FONT> </DIV>
<DIV><FONT face=3DTahoma color=3D#0000ff size=3D2>End=20
function</FONT></DIV></DIV></BODY></HTML>
------=_NextPart_000_001E_01C34A31.357E04D0--
Technical Details
Message-ID:
<ooAQa.29315$it4.777433@news1.tin.it>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-05!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!news-out.tin.it!news-in.tin.it!news1.tin.it.POSTED!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f94ee,e1daa8860c74ba7e,start X-Google-Attributes: gidf94ee,public X-Google-ArrivalTime: 2003-07-14 08:56:35 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-05!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!news-out.tin.it!news-in.tin.it!news1.tin.it.POSTED!not-for-mail From: "Michelangelo" <shinebox@shinesoftware.it> Newsgroups: free.it.visual-basic Subject: ADODB Help me Lines: 163 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_001E_01C34A31.357E04D0" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: <ooAQa.29315$it4.777433@news1.tin.it> Date: Mon, 14 Jul 2003 15:56:04 GMT NNTP-Posting-Host: 80.117.214.17 X-Complaints-To: newsmaster@tin.it X-Trace: news1.tin.it 1058198164 80.117.214.17 (Mon, 14 Jul 2003 17:56:04 MET DST) NNTP-Posting-Date: Mon, 14 Jul 2003 17:56:04 MET DST Organization: TIN