rafaelrgl
asked on
How to get the data from datatable and put on a sqldasource ??
Hi i have this Problem here, i have this object:
<asp:DropDownList ID="DDLEscolaridade" runat="server"
SkinID="ddlnormal" DataSourceID="ObjectDataSo urce1"
DataTextField="Escolaridad e" DataValueField="ID">
</asp:DropDownList>
and i have this function that i use on a webservice. so i will be calling this function from the webservice asmx.
<WebMethod()> _
Public Function GlobalTable_Get_Escolarida de() As DataTable
Dim Table As New DataTable()
Using connection As New SqlConnection(Configuratio nManager.C onnectionS trings("Gl obalNucleo Connection String").C onnectionS tring)
Using command As New SqlCommand("SP_Global_Get_ Escolarida de", connection)
command.CommandType = CommandType.StoredProcedur e
connection.Open()
Dim adapt As New SqlDataAdapter(command)
adapt.Fill(Table)
End Using
End Using
Return Table
End Function
how can i load this data inside this object. the datatable format is:
id escolaridade
1 sldjflsdf
2 lsdkjfljf
3 sdklfskjdfl
<asp:DropDownList ID="DDLEscolaridade" runat="server"
SkinID="ddlnormal" DataSourceID="ObjectDataSo
DataTextField="Escolaridad
</asp:DropDownList>
and i have this function that i use on a webservice. so i will be calling this function from the webservice asmx.
<WebMethod()> _
Public Function GlobalTable_Get_Escolarida
Dim Table As New DataTable()
Using connection As New SqlConnection(Configuratio
Using command As New SqlCommand("SP_Global_Get_
command.CommandType = CommandType.StoredProcedur
connection.Open()
Dim adapt As New SqlDataAdapter(command)
adapt.Fill(Table)
End Using
End Using
Return Table
End Function
how can i load this data inside this object. the datatable format is:
id escolaridade
1 sldjflsdf
2 lsdkjfljf
3 sdklfskjdfl
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
component:
<asp:DropDownList ID="DDLEscolaridade" runat="server" SkinID="ddlnormal" DataSourceID="ObjectDataSo urce1" DataTextField="Escolaridad e" DataValueField="ID">
</asp:DropDownList>
the code page:
Imports System.Data.SqlClient
Imports System.Data.SqlDbType
Imports System.Data
Partial Class _Default
Inherits SecurityPage
Dim GlobalNucleo As New GlobalNucleo_WebService.Gl obalNucleo _WebServic e
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
DDLEscolaridade.DataSource = GlobalNucleo.GlobalTable_G et_Escolar idade()
DDLEscolaridade.DataBind()
End Sub
End Class
Here is on the webservice:
<WebMethod()> _
Public Function GlobalTable_Get_Escolarida de() As DataTable
Dim Table As New DataTable()
Using connection As New SqlConnection(Configuratio nManager.C onnectionS trings("Gl obalNucleo Connection String").C onnectionS tring)
Using command As New SqlCommand("SP_Global_Get_ Escolarida de", connection)
command.CommandType = CommandType.StoredProcedur e
connection.Open()
Dim adapt As New SqlDataAdapter(command)
adapt.Fill(Table)
End Using
End Using
Return Table
End Function
here is the storeprocedure:
use [databasename]
GO
/****** Object: StoredProcedure [dbo].[SP_Global_Get_Escol aridade] Script Date: 09/14/2010 11:38:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[SP_Global_Get_Escol aridade]
AS
SELECT * from TB_GLOBAL_ESCOLARIDADE
RETURN
here is the table structure:
id escolaridade
1 highschool
2 lskjdf lsdjfls
3 sldjflskjdfljsldf
<asp:DropDownList ID="DDLEscolaridade" runat="server" SkinID="ddlnormal" DataSourceID="ObjectDataSo
</asp:DropDownList>
the code page:
Imports System.Data.SqlClient
Imports System.Data.SqlDbType
Imports System.Data
Partial Class _Default
Inherits SecurityPage
Dim GlobalNucleo As New GlobalNucleo_WebService.Gl
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
DDLEscolaridade.DataSource
DDLEscolaridade.DataBind()
End Sub
End Class
Here is on the webservice:
<WebMethod()> _
Public Function GlobalTable_Get_Escolarida
Dim Table As New DataTable()
Using connection As New SqlConnection(Configuratio
Using command As New SqlCommand("SP_Global_Get_
command.CommandType = CommandType.StoredProcedur
connection.Open()
Dim adapt As New SqlDataAdapter(command)
adapt.Fill(Table)
End Using
End Using
Return Table
End Function
here is the storeprocedure:
use [databasename]
GO
/****** Object: StoredProcedure [dbo].[SP_Global_Get_Escol
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[SP_Global_Get_Escol
AS
SELECT * from TB_GLOBAL_ESCOLARIDADE
RETURN
here is the table structure:
id escolaridade
1 highschool
2 lskjdf lsdjfls
3 sldjflskjdfljsldf
ASKER
btw, i add the webservice to the App_WebReferences
ASKER
found the solution:
here is how:
added this line to the webservice function:
Table.TableName = "Escolaridade"
here is how:
added this line to the webservice function:
Table.TableName = "Escolaridade"
ASKER
Thanks guys,
ASKER
System.Web.Services.Protoc
at System.Data.DataTable.Writ
at System.Data.DataTable.Syst
at System.Xml.Serialization.X
at Microsoft.Xml.Serializatio
at Microsoft.Xml.Serializatio
at System.Xml.Serialization.X
--- End of inner exception stack trace ---
at System.Xml.Serialization.X
at System.Web.Services.Protoc
at System.Web.Services.Protoc
at System.Web.Services.Protoc
--- End of inner exception stack trace ---