Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I connect to MSSQL7 data?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have a connection to the database but I cannot access data in a form. It is something to do with recordsets. Any help please?
 
The user that is used to login must have security to read the data. can you check what permissions the username has on the SQL7 database?
 
I can browse the data in Data View on right hand side. Just cannot get data into a form.
 
If you can show me your code it would make it a lot easier. What program are you using to create the form?
 
A very basic html form using the "new file option". I'm trying to connect to the northwind database on SQL7.

Thanks for your help.

<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE></TITLE>
</HEAD>
<BODY>

<P><INPUT id=text1 name=text1 dataFld=CustomerID dataSrc=Customers>
</P>
<P>
<!--METADATA TYPE=&quot;DesignerControl&quot; startspan
<OBJECT id=Textbox1 classid=clsid:B5F0E469-DC5F-11D0-9846-0000F8027CA0><PARAM NAME=&quot;_ExtentX&quot; VALUE=&quot;3175&quot;><PARAM NAME=&quot;_ExtentY&quot; VALUE=&quot;503&quot;><PARAM NAME=&quot;id&quot; VALUE=&quot;Textbox1&quot;><PARAM NAME=&quot;ControlType&quot; VALUE=&quot;0&quot;><PARAM NAME=&quot;Lines&quot; VALUE=&quot;3&quot;><PARAM NAME=&quot;DataSource&quot; VALUE=&quot;Cutomers&quot;><PARAM NAME=&quot;DataField&quot; VALUE=&quot;&quot;><PARAM NAME=&quot;Enabled&quot; VALUE=&quot;-1&quot;><PARAM NAME=&quot;Visible&quot; VALUE=&quot;-1&quot;><PARAM NAME=&quot;MaxChars&quot; VALUE=&quot;20&quot;><PARAM NAME=&quot;DisplayWidth&quot; VALUE=&quot;20&quot;><PARAM NAME=&quot;Platform&quot; VALUE=&quot;257&quot;><PARAM NAME=&quot;LocalPath&quot; VALUE=&quot;&quot;>
</OBJECT>
-->
<script language=&quot;JavaScript&quot; src=&quot;_ScriptLibrary/EventMgr.HTM&quot;></script>
<script language=&quot;JavaScript&quot; src=&quot;_ScriptLibrary/TextBox.HTM&quot;></script>
<SCRIPT LANGUAGE=JavaScript>
function _initTextbox1()
{
Textbox1.setStyle(TXT_TEXTBOX);
Textbox1.setDataSource(Cutomers);
Textbox1.setMaxLength(20);
Textbox1.setColumnCount(20);
}
CreateTextbox('Textbox1', _initTextbox1, null);
</script>

<!--METADATA TYPE=&quot;DesignerControl&quot; endspan-->
</P>
<P>&nbsp;</P>
<P>
</P>
<P>&nbsp;
</P>

</BODY>
</HTML>

 
I'm going to apologize right off, I don't use visual interdev or visual .net as a tool to write asp code. Looking at this though, there might be code in a folder/file called _ScriptLibrary/EventMgr.HTM that holds the connection strings and recordset strings. I'm not sure about that.

Here's what I would use as a conneciton string though:
'This assumes you're connected with a DSN
Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
objConn.Open &quot;DSN=DSNName;uid=SQLUserName;pwd=SQLUserNaemPWRD;&quot;

Set objRst = Server.CreateObject(&quot;ADODB.Recordset&quot;)
strSQL = &quot;Select * from Customers;&quot;
'Open your recordset
objRst.Open strSQL, objConn
'Next list out all the field names and values
objRst.Movefirst
While not objRst.eof
for each item in objRst.Fields
Response.Write item.Name & &quot;<br>&quot; & item.value
next
objRst.Movenext
Wend

To put them in form fields put in &quot;<input type=Text value='&quot; & objRst(&quot;FieldName&quot;).value & &quot;'>&quot; right before the reponse.write item.name like this:

Response.Write &quot;<input type=Text value='&quot; & objRst(&quot;FieldName&quot;).value & &quot;'>&quot;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top