Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: what is wrong ? connecting to sql DB...


Message #1 by "shay refaely" <shayr74@i...> on Wed, 28 Aug 2002 14:20:14
i am using the full release of VS.Net :
<%@Import Namespace ="System"%>
<%@Import Namespace ="System.Data"%>
<%@ Page Language="VB" Debug="true" %>
<%@Import Namespace ="System.Data.SqlClient"%>
<html>
	<head>
		<title>dataAccess</title>
		<script language="VB" runat="SERVER">
			Sub Page_Load (Sender As Object,E As EventArgs)
				Dim objConnection As SQLConnection
				Dim objCommand As SqlDataAdapter
				Dim strConnect As String
				Dim strCommand As String
				Dim ds1 As New DataSet

				strConnect 
= "server=rafa;uid=shay;pwd=;database=quizzer"
				strCommand = "select * from users"
				objConnection = New SQLConnection
(strConnect)
				 objCommand = NEW SqlDataAdapter
(strCommand,strConnect)
				objCommand.Fill(ds1,"users")
				DataGrid1.DataSource=ds1.Tables
("users").DefaultView
				DataGrid1.DataBind()
			End Sub
		</script>
	</head>
	<body>
		<asp:DataGrid ID="DataGrid1" Runat="server" />
	</body>
</html>



i just want to access the DB , i have the right permissions , but i cant 
get the problem.
Message #2 by Simon Hargreaves <simon.hargreaves@r...> on Wed, 28 Aug 2002 14:34:11 +0100
Hi Shay,

I have altered the strconnect below in your example, that might work better,
I am not sure but the order looks more like the examples we use, give it a
go and let me know how you get on, if not, we'll try some more to get it
going for you.

Sam

-----Original Message-----
From: shay refaely [mailto:shayr74@i...]
Sent: 28 August 2002 15:20
To: aspx_beginners
Subject: [aspx_beginners] what is wrong ? connecting to sql DB...


i am using the full release of VS.Net :
<%@Import Namespace ="System"%>
<%@Import Namespace ="System.Data"%>
<%@ Page Language="VB" Debug="true" %>
<%@Import Namespace ="System.Data.SqlClient"%>
<html>
	<head>
		<title>dataAccess</title>
		<script language="VB" runat="SERVER">
			Sub Page_Load (Sender As Object,E As EventArgs)
				Dim objConnection As SQLConnection
				Dim objCommand As SqlDataAdapter
				Dim strConnect As String
				Dim strCommand As String
				Dim ds1 As New DataSet

				strConnect 
"server=rafa;database=quizzer;uid=shay;pwd=;"
				strCommand = "select * from users"
				objConnection = New SQLConnection
(strConnect)
				 objCommand = NEW SqlDataAdapter
(strCommand,strConnect)
				objCommand.Fill(ds1,"users")
				DataGrid1.DataSource=ds1.Tables
("users").DefaultView
				DataGrid1.DataBind()
			End Sub
		</script>
	</head>
	<body>
		<asp:DataGrid ID="DataGrid1" Runat="server" />
	</body>
</html>



i just want to access the DB , i have the right permissions , but i cant 
get the problem.
---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=1861007418

These books look at how we can create data-centric ASP.NET 
applications. Requiring some basic knowledge of ASP.NET, 
Access and SQL the authors guide you through the process 
of connecting and consuming information in a variety of 
ways. They are packed full of excellent illustrative code 
examples, demonstrating important fundamental principles.
Message #3 by Berkay Mese <berkaymese@y...> on Wed, 28 Aug 2002 06:31:33 -0700 (PDT)
Please give the error produced by the compiler !
Does it mention about "Object not set referenced to an
instance", etc.. some message like that..
This code is accurate, but check the security settings
again and also adjust the code using the correct
syntax for convinience..

Berkay

--- shay refaely <shayr74@i...> wrote:
> i am using the full release of VS.Net :
> <%@Import Namespace ="System"%>
> <%@Import Namespace ="System.Data"%>
> <%@ Page Language="VB" Debug="true" %>
> <%@Import Namespace ="System.Data.SqlClient"%>
> <html>
> 	<head>
> 		<title>dataAccess</title>
> 		<script language="VB" runat="SERVER">
> 			Sub Page_Load (Sender As Object,E As EventArgs)
> 				Dim objConnection As SQLConnection
> 				Dim objCommand As SqlDataAdapter
> 				Dim strConnect As String
> 				Dim strCommand As String
> 				Dim ds1 As New DataSet
> 
> 				strConnect 
> = "server=rafa;uid=shay;pwd=;database=quizzer"
> 				strCommand = "select * from users"
> 				objConnection = New SQLConnection
> (strConnect)
> 				 objCommand = NEW SqlDataAdapter
> (strCommand,strConnect)
> 				objCommand.Fill(ds1,"users")
> 				DataGrid1.DataSource=ds1.Tables
> ("users").DefaultView
> 				DataGrid1.DataBind()
> 			End Sub
> 		</script>
> 	</head>
> 	<body>
> 		<asp:DataGrid ID="DataGrid1" Runat="server" />
> 	</body>
> </html>
> 
> 
> 
> i just want to access the DB , i have the right
> permissions , but i cant 
> get the problem.
> ---
> Beginning ASP.NET Databases using VB.NET
> http://www.wrox.com/ACON11.asp?ISBN=1861006195
> 
> Beginning ASP.NET Databases using C#
> http://www.wrox.com/ACON11.asp?ISBN=1861007418
> 
> These books look at how we can create data-centric
> ASP.NET 
> applications. Requiring some basic knowledge of
> ASP.NET, 
> Access and SQL the authors guide you through the
> process 
> of connecting and consuming information in a variety
> of 
> ways. They are packed full of excellent illustrative
> code 
> examples, demonstrating important fundamental
> principles.


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
Message #4 by "Hovik Melkomian" <melvik@b...> on Wed, 28 Aug 2002 18:57:09 +0430
I tryed ur code & it works fine! without any problem.

Thats all for now,
Hovik.



Message #5 by Simon Hargreaves <simon.hargreaves@r...> on Wed, 28 Aug 2002 16:11:49 +0100
In that case, one problem I had earlier was similar, the solution was go in
SQL Server enterprise manager, 
go - YourDataBase\Tools\Security and set security to SQL Server & Windows.

Solved it for me, so HtH

Sam

-----Original Message-----
From: Hovik Melkomian [mailto:melvik@b...]
Sent: 28 August 2002 15:27
To: aspx_beginners
Subject: [aspx_beginners] Re: what is wrong ? connecting to sql DB...


I tryed ur code & it works fine! without any problem.

Thats all for now,
Hovik.




---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=1861007418

These books look at how we can create data-centric ASP.NET 
applications. Requiring some basic knowledge of ASP.NET, 
Access and SQL the authors guide you through the process 
of connecting and consuming information in a variety of 
ways. They are packed full of excellent illustrative code 
examples, demonstrating important fundamental principles.

  Return to Index